Skip to content

Commit 5788e7b

Browse files
committed
Refactor benchmarking suite to use Criterion
1 parent 472e535 commit 5788e7b

14 files changed

+370
-198
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ flame.txt
1616
flamescope.json
1717
/wapm.lock
1818
/wapm_packages
19+
/.cargo/config

Cargo.lock

+185
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+13-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ members = [
1414
"derive", "jit", "parser", "vm", "vm/pylib-crate", "wasm/lib",
1515
]
1616

17-
[[bench]]
18-
name = "bench"
19-
path = "./benchmarks/bench.rs"
20-
2117
[features]
2218
default = ["threading", "pylib"]
2319
flame-it = ["rustpython-vm/flame-it", "flame", "flamescope"]
@@ -43,11 +39,22 @@ libc = "0.2"
4339
flame = { version = "0.2", optional = true }
4440
flamescope = { version = "0.1", optional = true }
4541

42+
cpython = "0.5.0"
43+
4644
[target.'cfg(not(target_os = "wasi"))'.dependencies]
4745
rustyline = "6.0"
4846

4947
[dev-dependencies]
5048
cpython = "0.5.0"
49+
criterion = "0.3"
50+
51+
[[bench]]
52+
name = "parsing"
53+
harness = false
54+
55+
[[bench]]
56+
name = "execution"
57+
harness = false
5158

5259
[[bin]]
5360
name = "rustpython"
@@ -63,3 +70,5 @@ opt-level = 3
6370
# crossbeam-utils = { git = "https://github.com/crossbeam-rs/crossbeam" }
6471
# socket2 = { git = "https://github.com/alexcrichton/socket2-rs" }
6572
# REDOX END
73+
74+
[target.bench]

benches/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Benchmarking
2+
3+
These are some files to determine performance of rustpython.
4+
5+
## Usage
6+
7+
Install pytest and pytest-benchmark:
8+
9+
$ pip install pytest-benchmark
10+
11+
Then run:
12+
13+
$ pytest
14+
15+
You can also benchmark the Rust benchmarks by just running
16+
`cargo bench` from the root of the repository. To view Python tracebacks during benchmarks,
17+
run `RUST_BACKTRACE=1 cargo bench`.
18+
19+
You can bench against a specific Python version by running:
20+
21+
```shell
22+
$ PYTHON_SYS_EXECUTABLE=python3.7 cargo bench
23+
```
24+
25+
On MacOS you will need to
26+
add the following to a `.cargo/config` file:
27+
28+
```toml
29+
[target.x86_64-apple-darwin]
30+
rustflags = [
31+
"-C", "link-arg=-undefined",
32+
"-C", "link-arg=dynamic_lookup",
33+
]
34+
```
35+
36+
## Benchmark source
37+
38+
- https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-python3-2.html
File renamed without changes.

0 commit comments

Comments
 (0)