Skip to content

Commit

Permalink
fix formatting issue with evmone
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Mar 31, 2020
1 parent 033e4ff commit aaaf8e1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion evm/scripts/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
EVMS = ["evmone", "parity", "geth", "cita-vm"]
RESULT_FILE = os.path.join(RESULT_CSV_OUTPUT_PATH + "evm_benchmarks.csv")

# translate a string representing a numerical field like '1.8M' to '1800000'
def format_evmone_benchmark(csv_line):
fields = csv_line.split(',')
gas_used = fields[-1]

if gas_used[-1].lower() == 'k':
gas_used = str(int(float(gas_used[:-1]) * 1000))
elif gas_used[-1].lower() == 'm':
gas_used = str(int(float(gas_used[:-1]) * 1000000))
else:
return csv_line

return ','.join(fields[:-1] + [gas_used])[:-1]

# merge benchmarks from multiple engines into one csv output
def main():
merged_csv_contents = 'engine, test_name, total_time, gas_used\n'
Expand All @@ -21,7 +35,10 @@ def main():

for i in range(1, len(evm_results[0])):
for e in range(0, len(EVMS)):
merged_csv_contents += evm_results[e][i] + '\n'
if EVMS[e] == 'evmone':
merged_csv_contents += format_evmone_benchmark(evm_results[e][i]) + '\n'
else:
merged_csv_contents += evm_results[e][i] + '\n'

with open(RESULT_FILE, 'w') as bench_result_file:
bench_result_file.write(merged_csv_contents)
Expand Down

0 comments on commit aaaf8e1

Please sign in to comment.