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

Commit

Permalink
Measure benchmark runtime in cycles per byte on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
milkey-mouse committed Jun 30, 2020
1 parent 1496561 commit ea55ccc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ version = "0.1.0"
authors = ["Heinz N. Gies <[email protected]>"]
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"
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
11 changes: 10 additions & 1 deletion benches/criterion_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,5 +50,11 @@ fn bench_all<T: Measurement>(c: &mut Criterion<T>) {
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);

0 comments on commit ea55ccc

Please sign in to comment.