The criterion_group macro defines a named collection of Criterion benchmark functions that run with shared configuration. Each group can use the default configuration or specified overrides, and criterion_main can run one or more groups. section 6.5
Registering a benchmark group
criterion_main!(python_vs_rust); criterion_group!(python_vs_rust, bench_fn); fn bench_fn(c: &mut Criterion) { c.bench_function("u8", |b| { b.iter(|| black_box(3u8 + 4)); }); } section 6.5
Listing 6.13 Basic benchmark example in benches/py-vs-rust.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
criterion_main!(python_vs_rust);
criterion_group!(python_vs_rust, bench_fn);
fn bench_fn(c: &mut Criterion) {
c.bench_function("u8", |b| {
b.iter(|| {
black_box(3u8 + 4);
});
});
c.bench_function("u128", |b| {
b.iter(|| {
black_box(3u128 + 4);
});
});
}
Inspect the complete benchmark file to see how criterion_group connects bench_fn with individual benchmark functions. section 6.5
