2023-09-04 21:55:20 -05:00
|
|
|
use fimg::*;
|
|
|
|
|
|
|
|
macro_rules! bench {
|
2023-10-01 16:19:15 -05:00
|
|
|
(fn $name: ident() { run $fn: ident() } $($namec:ident)?) => {
|
2023-09-06 22:02:44 -05:00
|
|
|
fn $name() {
|
2023-09-05 23:21:32 -05:00
|
|
|
let mut img: Image<_, 4> =
|
2023-09-21 18:52:40 -05:00
|
|
|
Image::build(128, 128).buf(include_bytes!("4_128x128.imgbuf").to_vec());
|
2023-09-06 22:02:44 -05:00
|
|
|
for _ in 0..256 {
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
unsafe {
|
|
|
|
img.$fn()
|
|
|
|
};
|
|
|
|
}
|
2023-09-04 21:55:20 -05:00
|
|
|
}
|
2023-10-01 16:19:15 -05:00
|
|
|
|
|
|
|
$(fn $namec() {
|
|
|
|
let img: Image<&[u8], 4> =
|
|
|
|
Image::build(128, 128).buf(include_bytes!("4_128x128.imgbuf"));
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
unsafe {
|
|
|
|
std::hint::black_box(img.cloner().$fn())
|
|
|
|
};
|
|
|
|
})?
|
2023-09-04 21:55:20 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-01 16:19:15 -05:00
|
|
|
bench!(fn flip_h() { run flip_h() } flip_hc);
|
|
|
|
bench!(fn flip_v() { run flip_v() } flip_vc);
|
|
|
|
bench!(fn rotate_90() { run rot_90() } rot_90c);
|
|
|
|
bench!(fn rotate_180() { run rot_180() } rot_180c);
|
2023-10-03 01:55:26 -05:00
|
|
|
bench!(fn rotate_270() { run rot_270() } rot_270c);
|
2023-10-01 16:19:15 -05:00
|
|
|
iai::main!(
|
|
|
|
flip_h, flip_v, rotate_90, rotate_180, rotate_270, flip_hc, flip_vc, rot_90c, rot_180c,
|
2023-10-03 01:55:26 -05:00
|
|
|
rot_270c
|
2023-10-01 16:19:15 -05:00
|
|
|
);
|