blob: e3693e74adbb5d7cb4ceff2a2529bf7226b07c81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#![feature(test)]
extern crate crossbeam_epoch as epoch;
extern crate crossbeam_utils as utils;
extern crate test;
use epoch::Owned;
use test::Bencher;
use utils::thread::scope;
#[bench]
fn single_alloc_defer_free(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
guard.defer_destroy(p);
}
});
}
#[bench]
fn single_defer(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
guard.defer(move || ());
});
}
#[bench]
fn multi_alloc_defer_free(b: &mut Bencher) {
const THREADS: usize = 16;
const STEPS: usize = 10_000;
b.iter(|| {
scope(|s| {
for _ in 0..THREADS {
s.spawn(|_| {
for _ in 0..STEPS {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
guard.defer_destroy(p);
}
}
});
}
})
.unwrap();
});
}
#[bench]
fn multi_defer(b: &mut Bencher) {
const THREADS: usize = 16;
const STEPS: usize = 10_000;
b.iter(|| {
scope(|s| {
for _ in 0..THREADS {
s.spawn(|_| {
for _ in 0..STEPS {
let guard = &epoch::pin();
guard.defer(move || ());
}
});
}
})
.unwrap();
});
}
|