mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add additional benchmarks to bit_set
This commit is contained in:
parent
3182375e06
commit
6e6608d8b5
@ -1,6 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
use std::hint::black_box;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -364,3 +365,36 @@ fn union_hybrid_sparse_full_small_domain(b: &mut Bencher) {
|
|||||||
sparse.union(&dense);
|
sparse.union(&dense);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_insert(b: &mut Bencher) {
|
||||||
|
let mut bs = BitSet::new_filled(99999usize);
|
||||||
|
b.iter(|| {
|
||||||
|
black_box(bs.insert(black_box(100u32)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_remove(b: &mut Bencher) {
|
||||||
|
let mut bs = BitSet::new_filled(99999usize);
|
||||||
|
b.iter(|| {
|
||||||
|
black_box(bs.remove(black_box(100u32)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_iter(b: &mut Bencher) {
|
||||||
|
let bs = BitSet::new_filled(99999usize);
|
||||||
|
b.iter(|| {
|
||||||
|
bs.iter().map(|b: usize| black_box(b)).for_each(drop);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_intersect(b: &mut Bencher) {
|
||||||
|
let mut ba: BitSet<u32> = BitSet::new_filled(99999usize);
|
||||||
|
let bb = BitSet::new_filled(99999usize);
|
||||||
|
b.iter(|| {
|
||||||
|
ba.intersect(black_box(&bb));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user