Skip to content

Commit

Permalink
git squash commit for iai-benchmarks.
Browse files Browse the repository at this point in the history
54671350698ec53bb67cb827bf86f96fcc2ba49f
.

7cfc1838cc3316f0b0ce0e567adf9df83d7cea59
.
  • Loading branch information
anforowicz committed Sep 28, 2023
1 parent f5021fb commit 16c5d82
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ criterion = "0.3.1"
getopts = "0.2.14"
glium = { version = "0.32", features = ["glutin"], default-features = false }
glob = "0.3"
iai = "0.1"
rand = "0.8.4"
term = "0.7"

Expand All @@ -50,3 +51,9 @@ path = "benches/unfilter.rs"
name = "unfilter"
harness = false
required-features = ["benchmarks"]

[[bench]]
path = "benches/decoder_iai.rs"
name = "decoder_iai"
harness = false

2 changes: 1 addition & 1 deletion benches/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ criterion_main!(benches);

fn bench_file(c: &mut Criterion, data: Vec<u8>, name: String) {
let mut group = c.benchmark_group("decode");
group.sample_size(20);
//group.sample_size(20);

let decoder = Decoder::new(&*data);
let mut reader = decoder.read_info().unwrap();
Expand Down
33 changes: 33 additions & 0 deletions benches/decoder_iai.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use iai::black_box;

fn decode(data: &[u8]) -> Vec<u8> {
let data = black_box(data);
let decoder = png::Decoder::new(data);
let mut reader = decoder.read_info().unwrap();
let mut image = vec![0; reader.output_buffer_size()];
reader.next_frame(&mut image).unwrap();
image
}

fn iai_decode_kodim02() -> Vec<u8> {
decode(include_bytes!("../tests/benches/kodim02.png"))
}

fn iai_decode_kodim07() -> Vec<u8> {
decode(include_bytes!("../tests/benches/kodim07.png"))
}

fn iai_decode_kodim17() -> Vec<u8> {
decode(include_bytes!("../tests/benches/kodim17.png"))
}

fn iai_decode_kodim23() -> Vec<u8> {
decode(include_bytes!("../tests/benches/kodim23.png"))
}

iai::main!{
iai_decode_kodim02,
iai_decode_kodim07,
iai_decode_kodim17,
iai_decode_kodim23,
}

0 comments on commit 16c5d82

Please sign in to comment.