Skip to content

Commit af9f4c9

Browse files
committed
Benchmark: Support cycles and remove file dependency
1 parent de0df5f commit af9f4c9

File tree

7 files changed

+598
-944
lines changed

7 files changed

+598
-944
lines changed

.github/workflows/ci.yml

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v2
1616

17-
- uses: actions/setup-python@v2
18-
with:
19-
python-version: 3.8
20-
21-
- name: Generate bench input
22-
run: python benches/geninput.py
23-
2417
- uses: actions-rs/toolchain@v1
2518
with:
2619
toolchain: stable

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ crate-type = ["staticlib", "rlib"]
1818
paste = "1.0"
1919

2020
[dev-dependencies]
21-
criterion = "0.3"
21+
criterion = {version = "0.3", features = ["html_reports"]}
2222
itertools = "0.10"
2323
rand = "0.8"
2424

25+
[target.'cfg(target_os="linux")'.dev-dependencies]
26+
perf-event = "0.4.6"
27+
2528
[[bench]]
2629
name = "benches"
2730
harness = false

README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,17 @@ Both standard range (0-235) and full range (0-255) are supported.
4545
## Requirements
4646

4747
* Rust 1.55 and newer (until DCP 0.2: At least Rust 1.39)
48-
* Python3 and Fractions module (needed only if you want to execute the benchmark)
4948

5049
### Windows
5150

5251
* Install rustup: https://www.rust-lang.org/tools/install
53-
* If you want to execute the benchmark:
54-
* Install Python 3: https://www.python.org/downloads/
55-
* Install fraction module: `pip install Fraction`
5652

5753
### Linux
5854

5955
* Install rustup (see https://forge.rust-lang.org/infra/other-installation-methods.html)
6056
```
6157
curl https://sh.rustup.rs -sSf | sh
6258
```
63-
* If you want to execute the benchmark:
64-
* Install Python 3 (example for Ubuntu): `apt install python3`
65-
* Install fraction module: `pip install Fraction`
6659
6760
You may require administrative privileges.
6861
@@ -87,10 +80,28 @@ cargo test
8780
8881
Run benchmark:
8982
```
90-
python benches/geninput.py
9183
cargo bench
9284
```
9385
86+
Advanced benchamark mode.
87+
There are two benchmark scripts:
88+
* `run-bench.ps1` for Windows
89+
* `run-bench.sh` for Linux and MacOS
90+
91+
They allow to obtain more stable results than `cargo bench`, by reducing variance due to:
92+
* CPU migration
93+
* File system caching
94+
* Process priority
95+
96+
Moreover, the Linux script support hardware performance counters, e.g. it is possible to output
97+
consumed CPU cycles instead of elapsed time.
98+
99+
Linux examples:
100+
```
101+
./run-bench -c 1 # runs cargo bench and outputs CPU cycles
102+
./run.bench -c 1 -p "/i420" # runs cargo bench, output CPU cycles, filtering tests that contains '/i420'
103+
```
104+
94105
## WebAssembly
95106
96107
Install the needed dependencies:

0 commit comments

Comments
 (0)