in benches/benches.rs [517:594]
fn bench(c: &mut Criterion<Perf>) {
let mut perf = PerfEvent::new();
for src_format in SRC_FORMATS {
let src_format_name = format!("{src_format}");
let mut group = c.benchmark_group(format!("{src_format_name:<4}"));
group.warm_up_time(Duration::from_secs(1));
group.measurement_time(Duration::from_secs(8));
group.sampling_mode(SamplingMode::Flat);
for i in 18..=26 {
let (width, height) = image_dimensions(i, *src_format);
group.throughput(Throughput::Elements((width as u64) * (height as u64)));
for dst_format in DST_FORMATS {
let dst_format_name = format!("{dst_format}");
group.bench_with_input(
BenchmarkId::new(format!("{dst_format_name:<4} {width:>4}x{height:<4}"), i),
&i,
|b, _i| {
b.iter_custom(|iters| {
let mut total = 0;
for j in 0..iters {
total += convert_from(
width,
height,
*src_format,
*dst_format,
make_seed(j),
&mut perf,
)
.expect("Benchmark iteration failed");
}
total
});
},
);
}
}
group.finish();
}
for src_format in DST_FORMATS {
let src_format_name = format!("{src_format}");
let mut group = c.benchmark_group(format!("{src_format_name:<4}"));
group.warm_up_time(Duration::from_secs(1));
group.measurement_time(Duration::from_secs(8));
group.sampling_mode(SamplingMode::Flat);
for i in 18..=26 {
let dst_format = PixelFormat::Bgra;
let dst_format_name = format!("{dst_format}");
let (width, height) = image_dimensions(i, dst_format);
group.throughput(Throughput::Elements((width as u64) * (height as u64)));
group.bench_with_input(
BenchmarkId::new(format!("{dst_format_name:<4} {width:>4}x{height:<4}"), i),
&i,
|b, _i| {
b.iter_custom(|iters| {
let mut total = 0;
for j in 0..iters {
total +=
convert_to(width, height, *src_format, make_seed(j), &mut perf)
.expect("Benchmark iteration failed");
}
total
});
},
);
}
group.finish();
}
}