diff --git a/src/filter/mod.rs b/src/filter/mod.rs index 22d6c8b6..24e0cb1d 100644 --- a/src/filter/mod.rs +++ b/src/filter/mod.rs @@ -1034,10 +1034,28 @@ mod benches { } }; } + macro_rules! bench_filter_clamped_rgb { + ($name:ident, $kernel_size:expr, $image_size:expr, $function_name:ident) => { + #[bench] + fn $name(b: &mut Bencher) { + let image = rgb_bench_image(500, 500); + + let kernel: Vec = (0..$kernel_size * $kernel_size).collect(); + let kernel = Kernel::new(&kernel, $kernel_size, $kernel_size); + b.iter(|| { + let filtered: Image> = $function_name::<_, _, i16>(&image, kernel); + black_box(filtered); + }); + } + }; + } bench_filter_clamped_gray!(bench_filter_clamped_gray_3x3, 3, 300, filter_clamped); bench_filter_clamped_gray!(bench_filter_clamped_gray_5x5, 5, 300, filter_clamped); bench_filter_clamped_gray!(bench_filter_clamped_gray_7x7, 7, 300, filter_clamped); + bench_filter_clamped_rgb!(bench_filter_clamped_rgb_3x3, 3, 300, filter_clamped); + bench_filter_clamped_rgb!(bench_filter_clamped_rgb_5x5, 5, 300, filter_clamped); + bench_filter_clamped_rgb!(bench_filter_clamped_rgb_7x7, 7, 300, filter_clamped); bench_filter_clamped_gray!( bench_filter_clamped_parallel_gray_3x3, @@ -1057,6 +1075,24 @@ mod benches { 300, filter_clamped_parallel ); + bench_filter_clamped_rgb!( + bench_filter_clamped_parallel_rgb_3x3, + 3, + 300, + filter_clamped_parallel + ); + bench_filter_clamped_rgb!( + bench_filter_clamped_parallel_rgb_5x5, + 5, + 300, + filter_clamped_parallel + ); + bench_filter_clamped_rgb!( + bench_filter_clamped_parallel_rgb_7x7, + 7, + 300, + filter_clamped_parallel + ); /// Baseline implementation of Gaussian blur is that provided by image::imageops. /// We can also use this to validate correctness of any implementations we add here.