Skip to content

Commit

Permalink
Benchmark TupleCombinations::fold
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet committed Oct 6, 2023
1 parent b014b06 commit 989d1df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions benches/bench1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,17 @@ fn permutations_slice(c: &mut Criterion) {
});
}

fn tuple_combinations_fold(c: &mut Criterion) {
let v = black_box((0..64).collect_vec());
c.bench_function("tuple_combinations fold", move |b| {
b.iter(|| {
v.iter()
.tuple_combinations()
.fold(0, |acc, (a, b, c, d)| acc + *a * *c - *b * *d)
})
});
}

criterion_group!(
benches,
slice_iter,
Expand Down Expand Up @@ -866,5 +877,6 @@ criterion_group!(
permutations_iter,
permutations_range,
permutations_slice,
tuple_combinations_fold,
);
criterion_main!(benches);

0 comments on commit 989d1df

Please sign in to comment.