From 784f7952de3576dfdeb5c5f7c50fc0dc843f12f0 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Thu, 2 Dec 2021 15:54:41 +0000 Subject: [PATCH] Remove criterion benches for now --- Cargo.toml | 13 +++-------- benches/bench.rs | 58 ------------------------------------------------ 2 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 benches/bench.rs diff --git a/Cargo.toml b/Cargo.toml index e27c5f1..d60f121 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/benches/bench.rs b/benches/bench.rs deleted file mode 100644 index e724152..0000000 --- a/benches/bench.rs +++ /dev/null @@ -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);