Skip to content

Commit b5869ed

Browse files
Benchmark TupleCombinations::fold
1 parent b8a77c4 commit b5869ed

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

benches/bench1.rs

+12
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,17 @@ fn with_position_fold(c: &mut Criterion) {
836836
});
837837
}
838838

839+
fn tuple_combinations_fold(c: &mut Criterion) {
840+
let v = black_box((0..64).collect_vec());
841+
c.bench_function("tuple_combinations fold", move |b| {
842+
b.iter(|| {
843+
v.iter()
844+
.tuple_combinations()
845+
.fold(0, |acc, (a, b, c, d)| acc + *a * *c - *b * *d)
846+
})
847+
});
848+
}
849+
839850
criterion_group!(
840851
benches,
841852
slice_iter,
@@ -884,5 +895,6 @@ criterion_group!(
884895
permutations_range,
885896
permutations_slice,
886897
with_position_fold,
898+
tuple_combinations_fold,
887899
);
888900
criterion_main!(benches);

0 commit comments

Comments
 (0)