Remove criterion benches for now

This commit is contained in:
Ivan Smirnov 2021-12-02 15:54:41 +00:00
parent bfbf032fff
commit 784f7952de
2 changed files with 3 additions and 68 deletions

View file

@ -12,22 +12,15 @@ documentation = "https://docs.rs/qoi-fast"
categories = ["multimedia::images", "multimedia::encoding"]
keywords = ["qoi", "graphics", "image", "encoding"]
exclude = [
"benches/*",
"assets/*",
]
[workspace]
members = ["qoi-bench"]
[dev-dependencies]
png = "^0.17.2"
[target.'cfg(bench)'.dev-dependencies]
# to activate, pass RUSTFLAGS="--cfg bench" until cargo does this automatically
criterion = "^0.3.5"
[lib]
name = "qoi_fast"
path = "src/lib.rs"
bench = false
[[bench]]
name = "bench"
harness = false

View file

@ -1,58 +0,0 @@
//! To run benchmarks, also pass RUSTFLAGS="--cfg bench" until cargo does this automatically.
use std::fs::File;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use qoi_fast::*;
pub fn criterion_benchmark(c: &mut Criterion) {
// let three_raw = include_bytes!("../assets/three.raw");
// let four_raw = include_bytes!("../assets/four.raw");
// let three_qoi = qoi_encode::<3>(three_raw, 572, 354).unwrap();
// c.bench_function("encode 3", |b| {
// b.iter(|| black_box(qoi_encode::<3>(three_raw, 572, 354).unwrap()))
// });
// c.bench_function("decode 3", |b| {
// b.iter(|| black_box(qoi_decode::<3>(&three_qoi).unwrap()))
// });
// c.bench_function("encode 4", |b| {
// b.iter(|| black_box(qoi_encode::<4>(four_raw, 572, 354).unwrap()))
// });
let decoder = png::Decoder::new(
File::open("/Users/ivansmirnov/projects/rust/qoi-other/images/kodak/kodim11.png").unwrap(),
);
let mut reader = decoder.read_info().unwrap();
let mut buf = vec![0; reader.output_buffer_size()];
let info = reader.next_frame(&mut buf).unwrap();
assert_eq!(info.color_type.samples(), 3);
let png_bytes = &buf[..info.buffer_size()];
let qoi_bytes = qoi_encode_to_vec(
png_bytes,
info.width as _,
info.height as _,
info.color_type.samples() as _,
)
.unwrap();
c.bench_function("kodim11.png (encode-3)", |b| {
b.iter(|| {
black_box(qoi_encode_to_vec(
png_bytes,
info.width as _,
info.height as _,
info.color_type.samples() as _,
))
.unwrap()
})
});
c.bench_function("kodim11.png (decode-3)", |b| {
b.iter(|| black_box(qoi_decode_to_vec(&qoi_bytes, 3)).unwrap())
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);