diff --git a/benches/decode.rs b/benches/decode.rs index 2f588bf..9ee683d 100644 --- a/benches/decode.rs +++ b/benches/decode.rs @@ -9,11 +9,11 @@ fn decode_buffer(c: &mut Criterion) { let mut group = c.benchmark_group("decode"); group + .throughput(Throughput::Bytes(length as u64)) .bench_function("decode 32k", move |b| { buf.clear(); b.iter(|| yenc::decode_buffer(&encoded).unwrap()) - }) - .throughput(Throughput::Bytes(length as u64)); + }); group.finish(); } @@ -32,6 +32,7 @@ fn decode_stream(c: &mut Criterion) { let mut group = c.benchmark_group("decode_stream"); group + .throughput(Throughput::Bytes(length as u64)) .bench_function("decode_stream 32k", move |b| { b.iter(|| { let i = input.clone(); @@ -39,8 +40,7 @@ fn decode_stream(c: &mut Criterion) { let options = yenc::DecodeOptions::new("/tmp"); options.decode_stream(&mut input_r).unwrap(); }); - }) - .throughput(Throughput::Bytes(length as u64)); + }); } criterion_group!(benches, decode_buffer, decode_stream); diff --git a/benches/encode.rs b/benches/encode.rs index 61f249c..0658b53 100644 --- a/benches/encode.rs +++ b/benches/encode.rs @@ -7,17 +7,18 @@ fn encode_buffer(c: &mut Criterion) { let mut output = Vec::with_capacity(32_768 * 102 / 100); let mut group = c.benchmark_group("encode"); group + .throughput(Throughput::Bytes(length as u64)) .bench_function("encode 32k", move |b| { b.iter(|| { output.clear(); yenc::encode_buffer(&buf, 0, 128, &mut output).unwrap() }) - }) - .throughput(Throughput::Bytes(length as u64)); + }); } fn encode_stream(c: &mut Criterion) { let mut group = c.benchmark_group("encode_stream"); group + .throughput(Throughput::Bytes(32_768)) .bench_function("encode_stream 32k", |b| { b.iter(|| { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::>(); @@ -31,8 +32,7 @@ fn encode_stream(c: &mut Criterion) { .encode_stream(&mut input_r, &mut output_r, length as u64, "test") .unwrap(); }) - }) - .throughput(Throughput::Bytes(32_768)); + }); } criterion_group!(benches, encode_buffer, encode_stream);