Skip to content

Commit ea26bc0

Browse files
authored
Use native Python and update results (#19)
1 parent da8eb4f commit ea26bc0

File tree

7 files changed

+47
-26
lines changed

7 files changed

+47
-26
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
evm-bench makes it easy to compare EVM performance in a scalable, standardized, and portable way.
88

9-
| | py-evm.cpython | py-evm.pypy | pyrevm | revm |
10-
| ----------------------- | -------------- | ----------- | ------- | ------ |
11-
| erc20.approval-transfer | 1.9362s | 424.2ms | 16.8ms | 9.8ms |
12-
| erc20.mint | 1.8968s | 374ms | 15ms | 5.6ms |
13-
| erc20.transfer | 2.7296s | 482.6ms | 23.4ms | 11.4ms |
14-
| snailtracer | 37.861s | 7.409s | 131.7ms | 60.7ms |
15-
| ten-thousand-hashes | 4.1496s | 632ms | 17ms | 6.8ms |
16-
| | | | | |
17-
| **sum** | 48.6s | 9.32s | 203ms | 94.3ms |
18-
| **relative** | 515x | 98.8x | 2.15x | 1.00x |
9+
| | py-evm.cpython | py-evm.pypy | pyrevm | revm |
10+
| ----------------------- | -------------- | ----------- | ------ | ------ |
11+
| erc20.approval-transfer | 1.4258s | 377.2ms | 16.8ms | 10ms |
12+
| erc20.mint | 1.4092s | 347.8ms | 14.4ms | 5.6ms |
13+
| erc20.transfer | 1.9988s | 420.8ms | 22.6ms | 11.4ms |
14+
| snailtracer | 17.857s | 5.17s | 138ms | 58ms |
15+
| ten-thousand-hashes | 3.4344s | 665.6ms | 18.2ms | 7ms |
16+
| | | | | |
17+
| **sum** | 26.1252s | 6.9814s | 210ms | 92ms |
18+
| **relative** | 284x | 75.9x | 2.28x | 1.00x |
1919

2020
To reproduce these results, check out [usage with the evm-bench suite below](#with-the-evm-bench-suite).
2121

benchmarks/snailtracer/benchmark.evm-bench.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../schema.json",
33
"name": "snailtracer",
4-
"num-runs": 3,
4+
"num-runs": 1,
55
"solc-version": "0.4.26",
66
"contract": "SnailTracer.sol",
77
"calldata": "30627b7c"

runners/py-evm/cpython/entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55

66
cd $SCRIPT_DIR
7-
poetry env use python3.9 >&2
7+
poetry env use python3 >&2
88
poetry install >&2
99
poetry update >&2
1010
poetry run python ../runner.py $@

runners/py-evm/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runners/py-evm/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = ""
55
authors = ["Ziyad Edher <ziyad.edher@gmail.com>"]
66

77
[tool.poetry.dependencies]
8-
python = "^3.9,<3.10"
8+
python = "^3.9"
99
py-evm = "^0.6.0-alpha.1"
1010

1111
[tool.poetry.dev-dependencies]

runners/py-evm/runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import argparse
2-
from typing import Final, cast
1+
from typing import cast, Final
32

3+
import argparse
44
import pathlib
55
import time
66

@@ -44,7 +44,7 @@ def _construct_chain() -> eth.chains.base.MiningChain:
4444
chain = chain_class.from_genesis(
4545
eth.db.atomic.AtomicDB(),
4646
genesis_params={
47-
"difficulty": 100,
47+
"difficulty": 1,
4848
"gas_limit": 2 * GAS_LIMIT,
4949
},
5050
)

src/results.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,52 @@ pub fn print_results(results_file_path: &Path) -> Result<(), Box<dyn error::Erro
101101
let mut runs = results.runs.into_iter().collect::<Vec<_>>();
102102
runs.sort_by_key(|(b, _)| b.clone());
103103

104+
let mut runner_times = HashMap::<String, Vec<Duration>>::new();
105+
104106
let mut builder = Builder::default();
105107
for (benchmark_name, benchmark_runs) in runs.iter() {
106108
let vals = runner_names.iter().map(|runner_name| {
107109
let run = benchmark_runs.get(runner_name)?;
108-
Some(
109-
run.run_times
110-
.iter()
111-
.fold(Duration::ZERO, |a, v| a + v.clone())
112-
.div_f64(run.run_times.len() as f64),
113-
)
110+
let avg_run_time = run
111+
.run_times
112+
.iter()
113+
.fold(Duration::ZERO, |a, v| a + v.clone())
114+
.div_f64(run.run_times.len() as f64);
115+
runner_times
116+
.entry(runner_name.clone())
117+
.or_default()
118+
.push(avg_run_time);
119+
Some(avg_run_time)
114120
});
121+
115122
let mut record = vec![benchmark_name.clone()];
116123
record.extend(
117124
vals.map(|val| Some(format!("{:?}", val?)))
118-
.map(|s| s.unwrap_or("".into())),
125+
.map(|s| s.unwrap_or_default()),
119126
);
120127
builder.add_record(record);
121128
}
122129

130+
let average_runner_times = runner_times
131+
.into_iter()
132+
.map(|(name, times)| (name, times.iter().sum::<Duration>()))
133+
.collect::<HashMap<String, Duration>>();
134+
let mut record = vec!["sum".to_string()];
135+
record.extend(
136+
runner_names
137+
.iter()
138+
.map(|runner_name| average_runner_times.get(runner_name))
139+
.map(|val| Some(format!("{:?}", val?)))
140+
.map(|s| s.unwrap_or_default()),
141+
);
142+
builder.add_record(record);
143+
123144
let mut columns = vec!["".to_owned()];
124145
columns.extend(runner_names);
125146
builder.set_columns(columns);
126147

127148
let mut table = builder.build();
128-
table.with(Style::rounded());
149+
table.with(Style::markdown());
129150
println!("{}", table);
130151

131152
Ok(())

0 commit comments

Comments
 (0)