1 | #![feature(test)] |
---|---|
2 | |
3 | extern crate test; |
4 | |
5 | use crossbeam_epoch as epoch; |
6 | use crossbeam_utils::thread::scope; |
7 | use test::Bencher; |
8 | |
9 | #[bench] |
10 | fn single_pin(b: &mut Bencher) { |
11 | b.iter(epoch::pin); |
12 | } |
13 | |
14 | #[bench] |
15 | fn multi_pin(b: &mut Bencher) { |
16 | const THREADS: usize = 16; |
17 | const STEPS: usize = 100_000; |
18 | |
19 | b.iter(|| { |
20 | scope(|s| { |
21 | for _ in 0..THREADS { |
22 | s.spawn(|_| { |
23 | for _ in 0..STEPS { |
24 | epoch::pin(); |
25 | } |
26 | }); |
27 | } |
28 | }) |
29 | .unwrap(); |
30 | }); |
31 | } |
32 |