diff --git a/Cargo.toml b/Cargo.toml index 68542d1..647581d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,9 @@ version = "0.1.0" authors = ["Heinz N. Gies "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - +[features] +default = ["cpb"] +cpb = [] [dev-dependencies] proptest = "0.10" @@ -13,6 +14,9 @@ criterion = "0.3" mimalloc = "0.1" core_affinity = "*" +[target.'cfg(any(target_arch = "x86_64", target_arch = "x86"))'.dev-dependencies] +criterion-cycles-per-byte = "0.1" + [[bench]] name = "criterion_bench" harness = false diff --git a/benches/criterion_bench.rs b/benches/criterion_bench.rs index 56198a8..cc792c9 100644 --- a/benches/criterion_bench.rs +++ b/benches/criterion_bench.rs @@ -2,6 +2,9 @@ extern crate core_affinity; #[macro_use] extern crate criterion; +#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "cpb"))] +use criterion_cycles_per_byte::CyclesPerByte; + use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; @@ -47,5 +50,11 @@ fn bench_all(c: &mut Criterion) { bench_file(c, "ascii_sample_ok", true); } -criterion_group!(benches, bench_all); +#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "cpb"))] +criterion_group! { + name = benches; + config = Criterion::default().with_measurement(CyclesPerByte); + targets = bench_all +} + criterion_main!(benches);