photosync/benches/image.rs

27 lines
985 B
Rust

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use image::imageops::FilterType;
use photosync::library::load_image;
use photosync::library::resize;
pub fn criterion_benchmark(c: &mut Criterion) {
const TEST_IMAGE_PATH: &'static str = "testdata/image.jpg";
let img = load_image(TEST_IMAGE_PATH).expect("failed to load test image");
c.bench_function("Load image", |b| {
b.iter(|| black_box(load_image(TEST_IMAGE_PATH)))
});
c.bench_function("Resize image full Nearest", |b| {
b.iter(|| black_box(resize(&img, (None, None), FilterType::Nearest)))
});
c.bench_function("Resize image full CatmullRom", |b| {
b.iter(|| black_box(resize(&img, (None, None), FilterType::CatmullRom)))
});
c.bench_function("Resize image full Lanczos3", |b| {
b.iter(|| black_box(resize(&img, (None, None), FilterType::Lanczos3)))
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);