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