-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace filter
with the old implementation
#654
Conversation
Can you show a benchmark comparison on your machine with a before/after this pr? I'll do the same on my machine as well. |
@ripytide I've just added a benchmark comparison on my machine on #644 (comment) (edit: for v0.25 to master). |
My Results on a
|
@ripytide can you also try with the benchmarks listed on #644 (comment) so we can get a consistent comparison between my benchmarking and yours. |
So on my machine the only massive change is the parallel_3x3 which is |
use std::{hint::black_box, time::Instant};
use imageproc::image::RgbImage;
const TRIES: usize = 20;
fn main() {
const W: u32 = 2600;
const H: u32 = W;
let img = black_box(RgbImage::new(W, H));
let kernel = black_box([0i32; 3 * 3]);
let t = Instant::now();
for _ in 0..TRIES {
let _: RgbImage = black_box(imageproc::filter::filter3x3(&img, &kernel));
}
dbg!(t.elapsed());
let ker = imgproc::kernel::Kernel::new(&kernel, 3, 3);
let t_new = Instant::now();
for _ in 0..TRIES {
let _: RgbImage = black_box(imgproc::filter::filter_clamped(&img, ker));
}
dbg!(t_new.elapsed());
} [dependencies]
imageproc = "0.25.0"
imgproc = { git = "https://github.com/image-rs/imageproc", branch = "master", package = "imageproc" } |
|
Interesting, I wonder what the difference between that test and the |
The regressions are much larger for RGB images: #644 (comment) Which might explain some of the difference between what your respective benchmarks are showing. I expect we're missing benchmarks on RGB images for quite a lot of functions in this crate! |
@theotherphil By the way, what should happen if |
The |
Should probably panic in that scenario, is there a compile-time assert function? |
Compile time assert is |
But we can't use this, for the same reason we can't allocate the stack by the number of channels |
The only way to do it in stable Rust is to add typenum in |
I wonder if we could use the |
@cospectrum I’d go with a runtime assert to check that channel counts match. Seems like a less likely user error than many of the places we already use panics to check preconditions. |
Done |
@cospectrum , @ripytide as both the function signatures and the set of benchmarks have changed since 0.25 comparisons across the two versions are a bit of a chore. So I'll merge this, check manually that performance now matches 0.25, and we can then use this commit as the baseline for future changes. |
where | ||
K: Copy, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having bounds in struct definitions is usually not best practise, bounds should appear where they are used.
#[inline] | ||
pub fn at(&self, x: u32, y: u32) -> &K { | ||
&self.data[(y * self.width + x) as usize] | ||
pub fn get(&self, x: u32, y: u32) -> K { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you rename at()
to get()
? This was discussed as not being a good idea as get()
normally returns an option.
)" This reverts commit 1cbe8d6.
Related #644