Add benchmark for Vec::retain
This commit is contained in:
parent
d1d8145dff
commit
20e14e4030
1 changed files with 15 additions and 0 deletions
|
@ -732,3 +732,18 @@ fn bench_flat_map_collect(b: &mut Bencher) {
|
|||
let v = vec![777u32; 500000];
|
||||
b.iter(|| v.iter().flat_map(|color| color.rotate_left(8).to_be_bytes()).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_retain_100000(b: &mut Bencher) {
|
||||
let v = (1..=100000).collect::<Vec<u32>>();
|
||||
b.iter(|| {
|
||||
let mut v = v.clone();
|
||||
v.retain(|x| x & 1 == 0)
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_retain_whole_100000(b: &mut Bencher) {
|
||||
let mut v = black_box(vec![826u32; 100000]);
|
||||
b.iter(|| v.retain(|x| *x == 826u32));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue