Skip to content

Commit

Permalink
Update criterion and switch to criterion-perf-events
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Nov 23, 2023
1 parent 06d1cd3 commit 82ad146
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ edition = "2018"
publish = false

[dependencies]
criterion = "0.3"
criterion = "0.5"
memchr = "2.4"
memmem = "0.1"
sliceslice = { path = ".." }
sse4-strstr = { path = "sse4-strstr", optional = true }
twoway = "0.2"

[target.'cfg(target_os = "linux")'.dependencies]
criterion-linux-perf = "0.1"
criterion-perf-events = "0.4.0"
perfcnt = "0.8"

[[bench]]
name = "i386"
Expand Down
6 changes: 4 additions & 2 deletions bench/benches/i386.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use criterion::{
Criterion,
};
#[cfg(target_os = "linux")]
use criterion_linux_perf::{PerfMeasurement, PerfMode};
use criterion_perf_events::Perf;
use memmem::{Searcher, TwoWaySearcher};
#[cfg(target_os = "linux")]
use perfcnt::linux::{HardwareEventType, PerfCounterBuilderLinux};
use std::{
fs::File,
io::{BufRead, BufReader},
Expand Down Expand Up @@ -295,7 +297,7 @@ criterion_group!(
#[cfg(target_os = "linux")]
criterion_group!(
name = i386_perf_instructions;
config = Criterion::default().with_measurement(PerfMeasurement::new(PerfMode::Instructions));
config = Criterion::default().with_measurement(Perf::new(PerfCounterBuilderLinux::from_hardware_event(HardwareEventType::Instructions)));
targets = search_short_haystack, search_long_haystack, search_random_haystack
);

Expand Down
6 changes: 4 additions & 2 deletions bench/benches/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use criterion::{
BenchmarkId, Criterion,
};
#[cfg(target_os = "linux")]
use criterion_linux_perf::{PerfMeasurement, PerfMode};
use criterion_perf_events::Perf;
use memmem::{Searcher, TwoWaySearcher};
#[cfg(target_os = "linux")]
use perfcnt::linux::{HardwareEventType, PerfCounterBuilderLinux};

fn search<M: Measurement>(c: &mut Criterion<M>) {
let haystack = include_str!("../../data/haystack");
Expand Down Expand Up @@ -105,7 +107,7 @@ criterion_group!(
#[cfg(target_os = "linux")]
criterion_group!(
name = random_perf_instructions;
config = Criterion::default().with_measurement(PerfMeasurement::new(PerfMode::Instructions));
config = Criterion::default().with_measurement(Perf::new(PerfCounterBuilderLinux::from_hardware_event(HardwareEventType::Instructions)));
targets = search
);

Expand Down

0 comments on commit 82ad146

Please sign in to comment.