Skip to content

Commit 451c72a

Browse files
Bench partition
1 parent 85d5077 commit 451c72a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

benches/bench1.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1+
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
22
use itertools::free::cloned;
33
use itertools::iproduct;
44
use itertools::Itertools;
@@ -648,6 +648,22 @@ fn step_range_10(c: &mut Criterion) {
648648
});
649649
}
650650

651+
fn vec_iter_mut_partition(c: &mut Criterion) {
652+
let data = std::iter::repeat(-1024i32..1024)
653+
.take(256)
654+
.flatten()
655+
.collect_vec();
656+
c.bench_function("vec iter mut partition", move |b| {
657+
b.iter_batched(
658+
|| data.clone(),
659+
|mut data| {
660+
black_box(itertools::partition(black_box(&mut data), |n| *n >= 0));
661+
},
662+
BatchSize::LargeInput,
663+
)
664+
});
665+
}
666+
651667
fn cartesian_product_iterator(c: &mut Criterion) {
652668
let xs = vec![0; 16];
653669

@@ -803,6 +819,7 @@ criterion_group!(
803819
step_vec_10,
804820
step_range_2,
805821
step_range_10,
822+
vec_iter_mut_partition,
806823
cartesian_product_iterator,
807824
multi_cartesian_product_iterator,
808825
cartesian_product_nested_for,

0 commit comments

Comments
 (0)