summaryrefslogtreecommitdiff
path: root/examples/profile.rs
blob: 9833c321c36f8f110fbaea7ff1a5f0d8bcd363ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 png = &large_image[..];
			let header = minipng::decode_png_header(png).unwrap();
			let mut buf = vec![0; header.required_bytes()];
			let data = minipng::decode_png(png, &mut buf).unwrap();
			std::hint::black_box(data);
		}
	}
}