1use criterion::{criterion_group, Criterion, Throughput};
2use std::time::Duration;
3
4const SIZE: usize = 1024 * 1024;
5
6fn large_drop(c: &mut Criterion) {
7 let mut group = c.benchmark_group("iter_with_large_drop");
8 group.throughput(Throughput::Bytes(SIZE as u64));
9 group.bench_function("large_drop", |b| {
10 let v: Vec<_> = (0..SIZE).map(|i| i as u8).collect();
11 b.iter_with_large_drop(|| v.clone());
12 });
13}
14
15fn small_drop(c: &mut Criterion) {
16 let mut group = c.benchmark_group("iter_with_large_drop");
17 group.bench_function("small_drop", |b| {
18 b.iter_with_large_drop(|| SIZE);
19 });
20}
21
22fn short_warmup() -> Criterion {
23 Criterion::default().warm_up_time(Duration::new(1, 0))
24}
25
26criterion_group! {
27 name = benches;
28 config = short_warmup();
29 targets = large_drop, small_drop
30}
31