diff options
author | pommicket <pommicket@gmail.com> | 2023-09-04 23:37:04 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-04 23:37:04 -0400 |
commit | 8c80e5ad4125cda33ddac130ee45d3d30f07181b (patch) | |
tree | 60f0d8a4a0b41c10568e097a70950cee98ac26d4 /examples | |
parent | 827122e165922c4010096c8d9ad32913ae06ab9e (diff) |
improve apply_filters performance
Diffstat (limited to 'examples')
-rw-r--r-- | examples/profile.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/profile.rs b/examples/profile.rs new file mode 100644 index 0000000..acc8154 --- /dev/null +++ b/examples/profile.rs @@ -0,0 +1,20 @@ +//! this file is just meant for profiling + +use std::hint::black_box; + +fn main() { + if cfg!(debug_assertions) { + eprintln!("this should only be run in release mode"); + } else { + println!("pid = {}", std::process::id()); + let large_image = black_box(std::fs::read("benches/large.png").unwrap()); + + for _ in 0..100 { + let mut png = &large_image[..]; + let header = tiny_png::read_png_header(&mut png).unwrap(); + let mut buf = vec![0; header.required_bytes()]; + let data = tiny_png::read_png(&mut png, Some(&header), &mut buf).unwrap(); + std::hint::black_box(data); + } + } +} |