| 1 |
use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
| 2 |
use itertools::Itertools; |
| 3 |
|
| 4 |
fn comb_replacement_n10_k5(c: &mut Criterion) { |
| 5 |
c.bench_function("comb replacement n10k5", move |b| { |
| 6 |
b.iter(|| { |
| 7 |
for i in (0..10).combinations_with_replacement(5) { |
| 8 |
black_box(i); |
| 9 |
} |
| 10 |
}) |
| 11 |
}); |
| 12 |
} |
| 13 |
|
| 14 |
fn comb_replacement_n5_k10(c: &mut Criterion) { |
| 15 |
c.bench_function("comb replacement n5 k10", move |b| { |
| 16 |
b.iter(|| { |
| 17 |
for i in (0..5).combinations_with_replacement(10) { |
| 18 |
black_box(i); |
| 19 |
} |
| 20 |
}) |
| 21 |
}); |
| 22 |
} |
| 23 |
|
| 24 |
fn comb_replacement_n10_k10(c: &mut Criterion) { |
| 25 |
c.bench_function("comb replacement n10 k10", move |b| { |
| 26 |
b.iter(|| { |
| 27 |
for i in (0..10).combinations_with_replacement(10) { |
| 28 |
black_box(i); |
| 29 |
} |
| 30 |
}) |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
criterion_group!( |
| 35 |
benches, |
| 36 |
comb_replacement_n10_k5, |
| 37 |
comb_replacement_n5_k10, |
| 38 |
comb_replacement_n10_k10, |
| 39 |
); |
| 40 |
criterion_main!(benches); |