Skip to content

Commit 8884771

Browse files
committed
Add relevant benchmarks
1 parent 1fd2f16 commit 8884771

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/libcore/benches/iter.rs

+28
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,31 @@ fn bench_skip_then_zip(b: &mut Bencher) {
306306
assert_eq!(s, 2009900);
307307
});
308308
}
309+
310+
#[bench]
311+
fn bench_filter_count(b: &mut Bencher) {
312+
b.iter(|| {
313+
(0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count()
314+
})
315+
}
316+
317+
#[bench]
318+
fn bench_filter_ref_count(b: &mut Bencher) {
319+
b.iter(|| {
320+
(0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
321+
})
322+
}
323+
324+
#[bench]
325+
fn bench_filter_chain_count(b: &mut Bencher) {
326+
b.iter(|| {
327+
(0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count()
328+
})
329+
}
330+
331+
#[bench]
332+
fn bench_filter_chain_ref_count(b: &mut Bencher) {
333+
b.iter(|| {
334+
(0i64..1000000).chain(0..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
335+
})
336+
}

0 commit comments

Comments
 (0)