Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit ea55ccc

Browse files
committed
Measure benchmark runtime in cycles per byte on x86
1 parent 1496561 commit ea55ccc

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ version = "0.1.0"
44
authors = ["Heinz N. Gies <[email protected]>"]
55
edition = "2018"
66

7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
7+
[features]
8+
default = ["cpb"]
9+
cpb = []
910

1011
[dev-dependencies]
1112
proptest = "0.10"
1213
criterion = "0.3"
1314
mimalloc = "0.1"
1415
core_affinity = "*"
1516

17+
[target.'cfg(any(target_arch = "x86_64", target_arch = "x86"))'.dev-dependencies]
18+
criterion-cycles-per-byte = "0.1"
19+
1620
[[bench]]
1721
name = "criterion_bench"
1822
harness = false

benches/criterion_bench.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ extern crate core_affinity;
22
#[macro_use]
33
extern crate criterion;
44

5+
#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "cpb"))]
6+
use criterion_cycles_per_byte::CyclesPerByte;
7+
58
use mimalloc::MiMalloc;
69
#[global_allocator]
710
static GLOBAL: MiMalloc = MiMalloc;
@@ -47,5 +50,11 @@ fn bench_all<T: Measurement>(c: &mut Criterion<T>) {
4750
bench_file(c, "ascii_sample_ok", true);
4851
}
4952

50-
criterion_group!(benches, bench_all);
53+
#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "cpb"))]
54+
criterion_group! {
55+
name = benches;
56+
config = Criterion::default().with_measurement(CyclesPerByte);
57+
targets = bench_all
58+
}
59+
5160
criterion_main!(benches);

0 commit comments

Comments
 (0)