diff options
author | Jakub Kotur <qtr@google.com> | 2020-12-21 17:28:14 +0100 |
---|---|---|
committer | Jakub Kotur <qtr@google.com> | 2021-03-05 15:05:06 +0100 |
commit | 704f579139cd14c990899a887026adce4b6fb0ac (patch) | |
tree | 8ab32923fe4a5e70e694e6147ea7f6783bc1b04b /benches/benchmarks/measurement_overhead.rs | |
parent | 71f53f93f889decb4b2faafb4eaea7b0e9c70722 (diff) | |
download | criterion-704f579139cd14c990899a887026adce4b6fb0ac.tar.gz |
Initial import of criterion-0.3.3.
Bug: 155309706
Change-Id: I8d6ee6f1995361f33b3b63527d1236f13de1ab0c
Diffstat (limited to 'benches/benchmarks/measurement_overhead.rs')
-rwxr-xr-x | benches/benchmarks/measurement_overhead.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/benches/benchmarks/measurement_overhead.rs b/benches/benchmarks/measurement_overhead.rs new file mode 100755 index 0000000..15b243d --- /dev/null +++ b/benches/benchmarks/measurement_overhead.rs @@ -0,0 +1,32 @@ +use criterion::{criterion_group, BatchSize, Criterion}; + +fn some_benchmark(c: &mut Criterion) { + let mut group = c.benchmark_group("overhead"); + group.bench_function("iter", |b| b.iter(|| 1)); + group.bench_function("iter_with_setup", |b| b.iter_with_setup(|| (), |_| 1)); + group.bench_function("iter_with_large_setup", |b| { + b.iter_with_large_setup(|| (), |_| 1) + }); + group.bench_function("iter_with_large_drop", |b| b.iter_with_large_drop(|| 1)); + group.bench_function("iter_batched_small_input", |b| { + b.iter_batched(|| (), |_| 1, BatchSize::SmallInput) + }); + group.bench_function("iter_batched_large_input", |b| { + b.iter_batched(|| (), |_| 1, BatchSize::LargeInput) + }); + group.bench_function("iter_batched_per_iteration", |b| { + b.iter_batched(|| (), |_| 1, BatchSize::PerIteration) + }); + group.bench_function("iter_batched_ref_small_input", |b| { + b.iter_batched_ref(|| (), |_| 1, BatchSize::SmallInput) + }); + group.bench_function("iter_batched_ref_large_input", |b| { + b.iter_batched_ref(|| (), |_| 1, BatchSize::LargeInput) + }); + group.bench_function("iter_batched_ref_per_iteration", |b| { + b.iter_batched_ref(|| (), |_| 1, BatchSize::PerIteration) + }); + group.finish(); +} + +criterion_group!(benches, some_benchmark); |