From f9eb08f7ca594dc0e559183997c96e91f0ae6faa Mon Sep 17 00:00:00 2001 From: Slixe Date: Thu, 18 Sep 2025 21:42:07 +0200 Subject: [PATCH 1/3] bench: update to new format --- bench/src/bench.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bench/src/bench.rs b/bench/src/bench.rs index 7a9b08e..696cf50 100644 --- a/bench/src/bench.rs +++ b/bench/src/bench.rs @@ -1,7 +1,7 @@ use std::time::Duration; use criterion::{ - criterion_group, criterion_main, Bencher, Benchmark, Criterion, Throughput, + criterion_group, criterion_main, Bencher, BenchmarkId, Criterion, Throughput, }; const CORPUS_HTML: &'static [u8] = include_bytes!("../../data/html"); @@ -157,15 +157,20 @@ fn define( group_name: &str, bench_name: &str, corpus: &[u8], - bench: impl FnMut(&mut Bencher) + 'static, + mut bench: impl FnMut(&mut Bencher) + 'static, ) { - let tput = Throughput::Bytes(corpus.len() as u64); - let benchmark = Benchmark::new(bench_name, bench) - .throughput(tput) - .sample_size(50) - .warm_up_time(Duration::from_millis(500)) - .measurement_time(Duration::from_secs(3)); - c.bench(group_name, benchmark); + let mut group = c.benchmark_group(group_name); + + group.throughput(Throughput::Bytes(corpus.len() as u64)); + group.sample_size(50); + group.warm_up_time(Duration::from_millis(500)); + group.measurement_time(Duration::from_secs(3)); + + group.bench_function(BenchmarkId::new(bench_name, corpus.len()), |b| { + bench(b); + }); + + group.finish(); } criterion_group!(g, all); From 60af476b89e23d7217c9c3c00ef1050b2c651ad2 Mon Sep 17 00:00:00 2001 From: Slixe Date: Thu, 18 Sep 2025 21:52:56 +0200 Subject: [PATCH 2/3] fix fmt --- bench/src/bench.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/src/bench.rs b/bench/src/bench.rs index 696cf50..8ddaf61 100644 --- a/bench/src/bench.rs +++ b/bench/src/bench.rs @@ -1,7 +1,8 @@ use std::time::Duration; use criterion::{ - criterion_group, criterion_main, Bencher, BenchmarkId, Criterion, Throughput, + criterion_group, criterion_main, Bencher, BenchmarkId, Criterion, + Throughput, }; const CORPUS_HTML: &'static [u8] = include_bytes!("../../data/html"); From 7e68fb947afe0a687aa236849987c0e103c6d43d Mon Sep 17 00:00:00 2001 From: Slixe Date: Thu, 18 Sep 2025 21:55:31 +0200 Subject: [PATCH 3/3] bench: no mut on bench fn --- bench/src/bench.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bench/src/bench.rs b/bench/src/bench.rs index 8ddaf61..e272518 100644 --- a/bench/src/bench.rs +++ b/bench/src/bench.rs @@ -158,18 +158,16 @@ fn define( group_name: &str, bench_name: &str, corpus: &[u8], - mut bench: impl FnMut(&mut Bencher) + 'static, + bench: impl FnMut(&mut Bencher) + 'static, ) { let mut group = c.benchmark_group(group_name); - group.throughput(Throughput::Bytes(corpus.len() as u64)); - group.sample_size(50); - group.warm_up_time(Duration::from_millis(500)); - group.measurement_time(Duration::from_secs(3)); - - group.bench_function(BenchmarkId::new(bench_name, corpus.len()), |b| { - bench(b); - }); + group + .throughput(Throughput::Bytes(corpus.len() as u64)) + .sample_size(50) + .warm_up_time(Duration::from_millis(500)) + .measurement_time(Duration::from_secs(3)) + .bench_function(BenchmarkId::new(bench_name, corpus.len()), bench); group.finish(); }