summaryrefslogtreecommitdiff
path: root/vendor/exr/benches/write.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/exr/benches/write.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/exr/benches/write.rs')
-rw-r--r--vendor/exr/benches/write.rs80
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/exr/benches/write.rs b/vendor/exr/benches/write.rs
new file mode 100644
index 0000000..14331c5
--- /dev/null
+++ b/vendor/exr/benches/write.rs
@@ -0,0 +1,80 @@
+#[macro_use]
+extern crate bencher;
+
+extern crate exr;
+use exr::prelude::*;
+
+use bencher::Bencher;
+use std::io::Cursor;
+
+fn write_parallel_any_channels_to_buffered(bench: &mut Bencher) {
+ let path = "tests/images/valid/custom/crowskull/crow_rle.exr";
+ let image = read_all_flat_layers_from_file(path).unwrap();
+
+ bench.iter(||{
+ let mut result = Vec::new();
+ image.write().to_buffered(Cursor::new(&mut result)).unwrap();
+ bencher::black_box(result);
+ })
+}
+
+fn write_parallel_zip1_to_buffered(bench: &mut Bencher) {
+ let path = "tests/images/valid/custom/crowskull/crow_rle.exr";
+
+ let mut image = read_first_flat_layer_from_file(path).unwrap();
+ image.layer_data.encoding.compression = Compression::ZIP1;
+
+ bench.iter(||{
+ let mut result = Vec::new();
+ image.write().to_buffered(Cursor::new(&mut result)).unwrap();
+ bencher::black_box(result);
+ })
+}
+
+fn write_nonparallel_zip1_to_buffered(bench: &mut Bencher) {
+ let path = "tests/images/valid/custom/crowskull/crow_rle.exr";
+
+ let mut image = read_first_flat_layer_from_file(path).unwrap();
+ image.layer_data.encoding.compression = Compression::ZIP1;
+
+ bench.iter(||{
+ let mut result = Vec::new();
+ image.write().non_parallel().to_buffered(Cursor::new(&mut result)).unwrap();
+ bencher::black_box(result);
+ })
+}
+
+fn write_parallel_zip16_to_buffered(bench: &mut Bencher) {
+ let path = "tests/images/valid/custom/crowskull/crow_rle.exr";
+
+ let mut image = read_first_flat_layer_from_file(path).unwrap();
+ image.layer_data.encoding.compression = Compression::ZIP16;
+
+ bench.iter(||{
+ let mut result = Vec::new();
+ image.write().to_buffered(Cursor::new(&mut result)).unwrap();
+ bencher::black_box(result);
+ })
+}
+
+fn write_uncompressed_to_buffered(bench: &mut Bencher) {
+ let path = "tests/images/valid/custom/crowskull/crow_uncompressed.exr";
+ let image = read_all_flat_layers_from_file(path).unwrap();
+ assert!(image.layer_data.iter().all(|layer| layer.encoding.compression == Compression::Uncompressed));
+
+ bench.iter(||{
+ let mut result = Vec::new();
+ image.write().to_buffered(Cursor::new(&mut result)).unwrap();
+ bencher::black_box(result);
+ })
+}
+
+benchmark_group!(write,
+ write_parallel_any_channels_to_buffered,
+ write_nonparallel_zip1_to_buffered,
+ write_parallel_zip1_to_buffered,
+ write_parallel_zip16_to_buffered,
+ write_uncompressed_to_buffered
+);
+
+benchmark_main!(write); \ No newline at end of file