Skip to content

Commit

Permalink
refactor(benchmarks): no need for BenchmarkId
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Feb 2, 2024
1 parent 20b8894 commit dcb8cb7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions benchmarks/benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::{self, Read};

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput};
use lockstitch::Protocol;

const LENS: &[(usize, &str)] =
Expand All @@ -11,7 +11,7 @@ fn hash(c: &mut Criterion) {
for &(len, id) in LENS {
let input = vec![0u8; len];
g.throughput(Throughput::Bytes(len as u64));
g.bench_with_input(BenchmarkId::from_parameter(id), &input, |b, input| {
g.bench_with_input(id, &input, |b, input| {
b.iter(|| {
let mut protocol = Protocol::new("hash");
protocol.mix("message", input);
Expand All @@ -26,7 +26,7 @@ fn hash_writer(c: &mut Criterion) {
let mut g = c.benchmark_group("hash-writer");
for &(len, id) in LENS {
g.throughput(Throughput::Bytes(len as u64));
g.bench_with_input(BenchmarkId::from_parameter(id), &len, |b, &len| {
g.bench_with_input(id, &len, |b, &len| {
b.iter_batched(
|| io::repeat(0u8).take(len as u64),
|mut input| {
Expand All @@ -50,7 +50,7 @@ fn stream(c: &mut Criterion) {
for &(len, id) in LENS {
let input = vec![0u8; len];
g.throughput(Throughput::Bytes(len as u64));
g.bench_with_input(BenchmarkId::from_parameter(id), &input, |b, input| {
g.bench_with_input(id, &input, |b, input| {
b.iter_batched_ref(
|| input.clone(),
|block| {
Expand All @@ -74,7 +74,7 @@ fn aead(c: &mut Criterion) {
for &(len, id) in LENS {
let input = vec![0u8; len];
g.throughput(Throughput::Bytes(len as u64));
g.bench_with_input(BenchmarkId::from_parameter(id), &input, |b, input| {
g.bench_with_input(id, &input, |b, input| {
b.iter_batched_ref(
|| input.clone(),
|block| {
Expand All @@ -96,7 +96,7 @@ fn prf(c: &mut Criterion) {
let mut g = c.benchmark_group("prf");
for &(len, id) in LENS {
g.throughput(Throughput::Bytes(len as u64));
g.bench_with_input(BenchmarkId::from_parameter(id), &len, |b, &len| {
g.bench_with_input(id, &len, |b, &len| {
let input = vec![0u8; len];
b.iter_batched_ref(
|| input.clone(),
Expand Down

0 comments on commit dcb8cb7

Please sign in to comment.