Debian Codegraph @

.cargo/vendor/exr/benches/profiling.rs

raw
1 #[macro_use]
2 extern crate bencher;
3
4 extern crate exr;
5 use exr::prelude::*;
6
7 use bencher::Bencher;
8 use std::fs;
9 use std::io::Cursor;
10 use exr::image::pixel_vec::PixelVec;
11
12 const PROFILING_REPETITIONS: i32 = 1; // make this 100 for profiling longer periods
13
14 /// This is a suuuper long benchmark, to allow you to hook up a profiler while running it
15 /// but this means we don't want it in our normal benchmarks
16 fn read_single_image_from_buffer_rgba_f32_as_f16(bench: &mut Bencher) {
17
18 let mut file = fs::read("tests/images/valid/custom/crowskull/crow_uncompressed.exr").unwrap();
19 bencher::black_box(&mut file);
20
21 bench.iter(||{
22 for _ in 0 .. PROFILING_REPETITIONS {
23 let image = exr::prelude::read()
24 .no_deep_data().largest_resolution_level()
25 .rgba_channels(PixelVec::<(f16,f16,f16,f16)>::constructor, PixelVec::set_pixel)
26 .first_valid_layer().all_attributes()
27 .non_parallel()
28 .from_buffered(Cursor::new(file.as_slice())).unwrap();
29
30 bencher::black_box(image);
31 }
32 })
33 }
34
35 benchmark_group!(profiling,
36 read_single_image_from_buffer_rgba_f32_as_f16
37 );
38
39 benchmark_main!(profiling);