When using parameterized benchmarks where input sizes scale exponentially, you can switch from the default linear axis to a logarithmic axis in generated plots. This is done by configuring a PlotConfiguration with AxisScale::Logarithmic and applying it to a BenchmarkGroup via .plot_config().
use criterion::*;
fn do_a_thing(x: u64) {}
fn bench(c: &mut Criterion) {
let plot_config = PlotConfiguration::default()
.summary_scale(AxisScale::Logarithmic);
let mut group = c.benchmark_group("log_scale_example");
group.plot_config(plot_config);
for i in [1u64, 10u64, 100u64, 1000u64].iter() {
group.bench_function(BenchmarkId::from_parameter(i), i, |b, i| b.iter(|| do_a_thing(i)));
}
group.finish();
}
criterion_group!(benches, bench);
criterion_main!(benches);