| 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 |
fn array_comb_replacement_n10_k5(c: &mut Criterion) { |
| 34 |
c.bench_function("array comb replacement n10k5", move |b| { |
| 35 |
b.iter(|| { |
| 36 |
for i in (0..10).array_combinations_with_replacement::<5>() { |
| 37 |
black_box(i); |
| 38 |
} |
| 39 |
}) |
| 40 |
}); |
| 41 |
} |
| 42 |
|
| 43 |
fn array_comb_replacement_n5_k10(c: &mut Criterion) { |
| 44 |
c.bench_function("array comb replacement n5 k10", move |b| { |
| 45 |
b.iter(|| { |
| 46 |
for i in (0..5).array_combinations_with_replacement::<10>() { |
| 47 |
black_box(i); |
| 48 |
} |
| 49 |
}) |
| 50 |
}); |
| 51 |
} |
| 52 |
|
| 53 |
fn array_comb_replacement_n10_k10(c: &mut Criterion) { |
| 54 |
c.bench_function("array comb replacement n10 k10", move |b| { |
| 55 |
b.iter(|| { |
| 56 |
for i in (0..10).array_combinations_with_replacement::<10>() { |
| 57 |
black_box(i); |
| 58 |
} |
| 59 |
}) |
| 60 |
}); |
| 61 |
} |
| 62 |
criterion_group!( |
| 63 |
benches, |
| 64 |
comb_replacement_n10_k5, |
| 65 |
comb_replacement_n5_k10, |
| 66 |
comb_replacement_n10_k10, |
| 67 |
array_comb_replacement_n10_k5, |
| 68 |
array_comb_replacement_n5_k10, |
| 69 |
array_comb_replacement_n10_k10, |
| 70 |
); |
| 71 |
criterion_main!(benches); |