Skip to content

Commit

Permalink
Add criterion benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Oct 11, 2022
1 parent 98ce681 commit 0b915d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ bytemuck = "1.12"

[dev-dependencies]
image = "0.24"
criterion = "0.3"

[[bench]]
name = "decoding"
harness = false
27 changes: 27 additions & 0 deletions benches/decoding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use criterion::{criterion_group, criterion_main, Criterion};
use dtm::DTM;

fn decode_full_png() {
let _data_png = image::open("data/N265E425.png").unwrap();
}

fn decode_full_dtm() {
let (_descriptor, _data_dtm) = DTM::decode_file("data/N265E425.dtm").unwrap();
}

fn decode_full_tif() {
let _data_tif = image::open("data/N265E425.tif").unwrap();
}

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("png full", |b| b.iter(|| decode_full_png()));
c.bench_function("dtm full", |b| b.iter(|| decode_full_dtm()));
c.bench_function("tif full", |b| b.iter(|| decode_full_tif()));
}

criterion_group! {
name = benches;
config = Criterion::default().sample_size(10);
targets = criterion_benchmark
}
criterion_main!(benches);

0 comments on commit 0b915d1

Please sign in to comment.