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