benchmarks comparing the rust image processing ecosystem
Diffstat (limited to 'benches/resizing.rs')
-rw-r--r--benches/resizing.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/benches/resizing.rs b/benches/resizing.rs
new file mode 100644
index 0000000..fc26eae
--- /dev/null
+++ b/benches/resizing.rs
@@ -0,0 +1,50 @@
+use fimg::Image;
+const SIZE: u32 = 5424;
+const TO: u32 = 2712;
+
+macro_rules! scale_fimg {
+ ($name:ident => { scale($alg: ident) }) => {
+ fn $name() {
+ #[allow(unused_mut)]
+ let mut img = Image::<_, 3>::build(SIZE, SIZE)
+ .buf(iai::black_box(include_bytes!("../data.imgbuf").to_vec()));
+ img.scale::<fimg::scale::$alg>(TO, TO);
+ iai::black_box(img);
+ }
+ };
+}
+
+macro_rules! scale_img {
+ ($name:ident => { scale($alg: ident) }) => {
+ fn $name() {
+ let img = image::RgbImage::from_raw(
+ SIZE,
+ SIZE,
+ iai::black_box(include_bytes!("../data.imgbuf").to_vec()),
+ )
+ .unwrap();
+ iai::black_box(image::imageops::resize(
+ &img,
+ TO,
+ TO,
+ image::imageops::FilterType::$alg,
+ ));
+ }
+ };
+}
+
+scale_fimg!(nearest_fimg => { scale(Nearest) });
+scale_img!(nearest_img => { scale(Nearest) });
+scale_fimg!(lanczos_fimg => { scale(Lanczos3) });
+scale_img!(lanczos_img => { scale(Lanczos3) });
+scale_fimg!(catmull_fimg => { scale(CatmullRom) });
+scale_img!(catmull_img => { scale(CatmullRom) });
+
+iai::main!(
+ nearest_fimg,
+ nearest_img,
+ lanczos_fimg,
+ lanczos_img,
+ catmull_fimg,
+ catmull_img
+);