Skip to content

Commit

Permalink
fix criterion's deprecation warnings for the ini benches
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc authored and Geal committed Aug 5, 2021
1 parent c866032 commit 2915439
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
36 changes: 15 additions & 21 deletions benches/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ port=143
file=payroll.dat
\0";

c.bench(
"bench ini",
Benchmark::new("parse", move |b| {
b.iter(|| categories(str.as_bytes()).unwrap());
})
.throughput(Throughput::Bytes(str.len() as u64)),
);
let mut group = c.benchmark_group("ini");
group.throughput(Throughput::Bytes(str.len() as u64));
group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
b.iter(|| categories(str.as_bytes()).unwrap())
});
}

fn bench_ini_keys_and_values(c: &mut Criterion) {
Expand All @@ -78,25 +76,21 @@ file=payroll.dat
many0(key_value)(i)
}

c.bench(
"bench ini keys and values",
Benchmark::new("parse", move |b| {
b.iter(|| acc(str.as_bytes()).unwrap());
})
.throughput(Throughput::Bytes(str.len() as u64)),
);
let mut group = c.benchmark_group("ini keys and values");
group.throughput(Throughput::Bytes(str.len() as u64));
group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
b.iter(|| acc(str.as_bytes()).unwrap())
});
}

fn bench_ini_key_value(c: &mut Criterion) {
let str = "server=192.0.2.62\n";

c.bench(
"bench ini key value",
Benchmark::new("parse", move |b| {
b.iter(|| key_value(str.as_bytes()).unwrap());
})
.throughput(Throughput::Bytes(str.len() as u64)),
);
let mut group = c.benchmark_group("ini key value");
group.throughput(Throughput::Bytes(str.len() as u64));
group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
b.iter(|| key_value(str.as_bytes()).unwrap())
});
}

criterion_group!(
Expand Down
12 changes: 5 additions & 7 deletions benches/ini_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ port=143
file=payroll.dat
";

c.bench(
"bench ini str",
Benchmark::new("parse", move |b| {
b.iter(|| categories(s).unwrap());
})
.throughput(Throughput::Bytes(s.len() as u64)),
);
let mut group = c.benchmark_group("ini str");
group.throughput(Throughput::Bytes(s.len() as u64));
group.bench_function(BenchmarkId::new("parse", s.len()), |b| {
b.iter(|| categories(s).unwrap())
});
}

criterion_group!(benches, bench_ini_str);
Expand Down

0 comments on commit 2915439

Please sign in to comment.