use criterion::{Criterion, criterion_group, criterion_main}; use image::ImageReader; const LIST_OF_SAMPLES: [&str; 7] = [ "samples/david.png", "samples/david2.jpg", "samples/us.png", "samples/diderot_111.png", "samples/jane.jpg", "samples/jane2.webp", "samples/karel_käos.jpg", ]; pub fn bench_random(c: &mut Criterion) { let img = ImageReader::open(LIST_OF_SAMPLES[1]) .unwrap() .decode() .unwrap() .into_rgb8(); c.bench_function("dither random", |b| { b.iter(|| { let mut img = img.clone(); dither::dither_random(&mut img) }) }); } pub fn bench_random_color(c: &mut Criterion) { let img = ImageReader::open(LIST_OF_SAMPLES[1]) .unwrap() .decode() .unwrap() .into_rgb8(); c.bench_function("dither random", |b| { b.iter(|| { let mut img = img.clone(); dither::dither_random_color(&mut img) }) }); } criterion_group!(random, bench_random, bench_random_color); criterion_main!(random);