Refactor for testing.

This commit is contained in:
2020-02-20 20:19:27 -08:00
parent b552b922fa
commit df28512450
4 changed files with 68 additions and 19 deletions

26
benches/image.rs Normal file
View File

@@ -0,0 +1,26 @@
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);