1use std::iter;
2
3use criterion::{criterion_group, BenchmarkId, Criterion, Throughput};
4
5fn from_elem(c: &mut Criterion) {
6 static KB: usize = 1024;
7
8 let mut group = c.benchmark_group("from_elem");
9 for size in [KB, 2 * KB, 4 * KB, 8 * KB, 16 * KB].iter() {
10 group.throughput(Throughput::Bytes(*size as u64));
11 group.bench_with_input(BenchmarkId::from_parameter(size), size, |b, &size| {
12 b.iter(|| iter::repeat(0u8).take(size).collect::<Vec<_>>());
13 });
14 }
15 group.finish();
16
17 let mut group = c.benchmark_group("from_elem_decimal");
18 for size in [KB, 2 * KB].iter() {
19 group.throughput(Throughput::BytesDecimal(*size as u64));
20 group.bench_with_input(BenchmarkId::from_parameter(size), size, |b, &size| {
21 b.iter(|| iter::repeat(0u8).take(size).collect::<Vec<_>>());
22 });
23 }
24 group.finish();
25}
26
27criterion_group!(benches, from_elem);
28