Skip to content

Commit cbe87cb

Browse files
Benchmark TupleCombinations::fold
1 parent 6710e71 commit cbe87cb

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
@@ -855,6 +855,17 @@ fn with_position_fold(c: &mut Criterion) {
855855
});
856856
}
857857

858+
fn tuple_combinations_fold(c: &mut Criterion) {
859+
let v = black_box((0..64).collect_vec());
860+
c.bench_function("tuple_combinations fold", move |b| {
861+
b.iter(|| {
862+
v.iter()
863+
.tuple_combinations()
864+
.fold(0, |acc, (a, b, c, d)| acc + *a * *c - *b * *d)
865+
})
866+
});
867+
}
868+
858869
criterion_group!(
859870
benches,
860871
slice_iter,
@@ -903,6 +914,7 @@ criterion_group!(
903914
permutations_range,
904915
permutations_slice,
905916
with_position_fold,
917+
tuple_combinations_fold,
906918
while_some,
907919
);
908920
criterion_main!(benches);

0 commit comments

Comments
 (0)