Crates.io | criterion-linux-perf |
lib.rs | criterion-linux-perf |
version | 0.1.0 |
source | src |
created_at | 2020-12-22 19:39:03.378219 |
updated_at | 2020-12-22 19:39:03.378219 |
description | A measurement plugin for Criterion.rs that provides measurements using Linux's perf interface |
homepage | |
repository | https://github.com/bruceg/criterion-linux-perf |
max_upload_size | |
id | 326150 |
size | 9,210 |
This is a measurement plugin for Criterion.rs that provides measurements using Linux's perf interface.
criterion-linux-perf uses the
perf-event
crate and
supports a subset of the events provided by that crate. If you require
more events than the current selection, please open an
issue to request
additions.
The following code shows on how to count branches when creating an empty string:
use criterion::{criterion_group, criterion_main, Criterion};
use criterion_linux_perf::{PerfMeasurement, PerfMode};
fn timeit(crit: &mut Criterion<PerfMeasurement>) {
crit.bench_function("String::new", |b| b.iter(|| String::new()));
crit.bench_function("String::from", |b| b.iter(|| String::from("")));
}
criterion_group!(
name = benches;
config = Criterion::default().with_measurement(PerfMeasurement::new(PerfMode::Branches));
targets = timeit
);
criterion_main!(benches);
I am aware of one other crate that provides the same functionality,
criterion-perf-events
. While
it provides a much wider coverage of the available perf event types, it
depends on perfcnt
which only
builds on Rust nightly. This crate depends on
perf-event
, which does not
have that limitation.