]> git.proxmox.com Git - rustc.git/blame - vendor/crossbeam-epoch-0.8.2/benches/pin.rs
New upstream version 1.59.0+dfsg1
[rustc.git] / vendor / crossbeam-epoch-0.8.2 / benches / pin.rs
CommitLineData
5869c6ff
XL
1#![feature(test)]
2
3extern crate crossbeam_epoch as epoch;
4extern crate crossbeam_utils as utils;
5extern crate test;
6
7use test::Bencher;
8use utils::thread::scope;
9
10#[bench]
11fn single_pin(b: &mut Bencher) {
12 b.iter(|| epoch::pin());
13}
14
15#[bench]
16fn 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}