|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; |
18 | | -use pushpin::core::arena; |
| 18 | +use pushpin::core::memorypool; |
19 | 19 | use std::cell::RefCell; |
20 | 20 | use std::mem; |
21 | 21 | use std::rc::Rc; |
22 | 22 |
|
23 | | -fn bench_arena_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) { |
| 23 | +fn bench_mp_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) { |
24 | 24 | let bytes = mem::size_of::<[u64; N]>(); |
25 | | - let memory = Rc::new(arena::RcMemory::new(op_count)); |
| 25 | + let memory = Rc::new(memorypool::RcMemory::new(op_count)); |
26 | 26 | let instances = RefCell::new(Vec::with_capacity(op_count)); |
27 | 27 |
|
28 | | - c.bench_function(&format!("arena rc new {bytes}b x{op_count}"), |b| { |
| 28 | + c.bench_function(&format!("mp rc new {bytes}b x{op_count}"), |b| { |
29 | 29 | b.iter_batched_ref( |
30 | 30 | || instances.borrow_mut().clear(), |
31 | 31 | |_| { |
32 | 32 | let instances = &mut *instances.borrow_mut(); |
33 | 33 | let mut next_value: [u64; N] = [0; N]; |
34 | 34 | while next_value[0] < op_count as u64 { |
35 | | - let n = arena::Rc::new(next_value, &memory).unwrap(); |
| 35 | + let n = memorypool::Rc::new(next_value, &memory).unwrap(); |
36 | 36 | instances.push(n); |
37 | 37 | next_value[0] += 1; |
38 | 38 | } |
@@ -63,18 +63,18 @@ fn bench_std_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) { |
63 | 63 | }); |
64 | 64 | } |
65 | 65 |
|
66 | | -fn bench_arena_rc_drop<const N: usize>(c: &mut Criterion, op_count: usize) { |
| 66 | +fn bench_mp_rc_drop<const N: usize>(c: &mut Criterion, op_count: usize) { |
67 | 67 | let bytes = mem::size_of::<[u64; N]>(); |
68 | | - let memory = Rc::new(arena::RcMemory::new(op_count)); |
| 68 | + let memory = Rc::new(memorypool::RcMemory::new(op_count)); |
69 | 69 | let instances = RefCell::new(Vec::with_capacity(op_count)); |
70 | 70 |
|
71 | | - c.bench_function(&format!("arena rc drop {bytes}b x{op_count}"), |b| { |
| 71 | + c.bench_function(&format!("mp rc drop {bytes}b x{op_count}"), |b| { |
72 | 72 | b.iter_batched_ref( |
73 | 73 | || { |
74 | 74 | let instances = &mut *instances.borrow_mut(); |
75 | 75 | let mut next_value: [u64; N] = [0; N]; |
76 | 76 | while next_value[0] < op_count as u64 { |
77 | | - let n = arena::Rc::new(next_value, &memory).unwrap(); |
| 77 | + let n = memorypool::Rc::new(next_value, &memory).unwrap(); |
78 | 78 | instances.push(n); |
79 | 79 | next_value[0] += 1; |
80 | 80 | } |
@@ -111,24 +111,24 @@ fn criterion_benchmark(c: &mut Criterion) { |
111 | 111 |
|
112 | 112 | { |
113 | 113 | // Preallocate the instances |
114 | | - let memory = Rc::new(arena::RcMemory::new(OP_COUNT)); |
| 114 | + let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT)); |
115 | 115 | let mut instances = Vec::new(); |
116 | 116 | let mut next_value: u64 = 0; |
117 | 117 | while next_value < OP_COUNT as u64 { |
118 | | - let n = arena::Rc::new(next_value, &memory).unwrap(); |
| 118 | + let n = memorypool::Rc::new(next_value, &memory).unwrap(); |
119 | 119 | instances.push(n); |
120 | 120 | next_value += 1; |
121 | 121 | } |
122 | 122 |
|
123 | 123 | let clones = RefCell::new(Vec::with_capacity(instances.len())); |
124 | 124 |
|
125 | | - c.bench_function(&format!("arena rc clone x{OP_COUNT}"), |b| { |
| 125 | + c.bench_function(&format!("mp rc clone x{OP_COUNT}"), |b| { |
126 | 126 | b.iter_batched_ref( |
127 | 127 | || clones.borrow_mut().clear(), |
128 | 128 | |_| { |
129 | 129 | let clones = &mut *clones.borrow_mut(); |
130 | 130 | for r in &instances { |
131 | | - clones.push(arena::Rc::clone(&r)); |
| 131 | + clones.push(memorypool::Rc::clone(&r)); |
132 | 132 | } |
133 | 133 | }, |
134 | 134 | BatchSize::PerIteration, |
@@ -164,23 +164,23 @@ fn criterion_benchmark(c: &mut Criterion) { |
164 | 164 |
|
165 | 165 | { |
166 | 166 | // Preallocate the instances |
167 | | - let memory = Rc::new(arena::RcMemory::new(OP_COUNT)); |
| 167 | + let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT)); |
168 | 168 | let mut instances = Vec::new(); |
169 | 169 | let mut next_value: u64 = 0; |
170 | 170 | while next_value < OP_COUNT as u64 { |
171 | | - let n = arena::Rc::new(next_value, &memory).unwrap(); |
| 171 | + let n = memorypool::Rc::new(next_value, &memory).unwrap(); |
172 | 172 | instances.push(n); |
173 | 173 | next_value += 1; |
174 | 174 | } |
175 | 175 |
|
176 | 176 | let clones = RefCell::new(Vec::with_capacity(instances.len())); |
177 | 177 |
|
178 | | - c.bench_function(&format!("arena rc dec x{OP_COUNT}"), |b| { |
| 178 | + c.bench_function(&format!("mp rc dec x{OP_COUNT}"), |b| { |
179 | 179 | b.iter_batched_ref( |
180 | 180 | || { |
181 | 181 | let clones = &mut *clones.borrow_mut(); |
182 | 182 | for r in &instances { |
183 | | - clones.push(arena::Rc::clone(r)) |
| 183 | + clones.push(memorypool::Rc::clone(r)) |
184 | 184 | } |
185 | 185 | }, |
186 | 186 | |_| clones.borrow_mut().clear(), |
@@ -217,16 +217,16 @@ fn criterion_benchmark(c: &mut Criterion) { |
217 | 217 |
|
218 | 218 | { |
219 | 219 | // Preallocate the instances |
220 | | - let memory = Rc::new(arena::RcMemory::new(OP_COUNT)); |
| 220 | + let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT)); |
221 | 221 | let mut instances = Vec::new(); |
222 | 222 | let mut next_value: u64 = 0; |
223 | 223 | while next_value < OP_COUNT as u64 { |
224 | | - let n = arena::Rc::new(next_value, &memory).unwrap(); |
| 224 | + let n = memorypool::Rc::new(next_value, &memory).unwrap(); |
225 | 225 | instances.push(n); |
226 | 226 | next_value += 1; |
227 | 227 | } |
228 | 228 |
|
229 | | - c.bench_function(&format!("arena rc deref x{OP_COUNT}"), |b| { |
| 229 | + c.bench_function(&format!("mp rc deref x{OP_COUNT}"), |b| { |
230 | 230 | b.iter(|| { |
231 | 231 | for (expected_value, r) in instances.iter().enumerate() { |
232 | 232 | assert_eq!(*r.get(), expected_value as u64); |
@@ -254,22 +254,22 @@ fn criterion_benchmark(c: &mut Criterion) { |
254 | 254 | }); |
255 | 255 | } |
256 | 256 |
|
257 | | - bench_arena_rc_new::<1>(c, OP_COUNT); |
| 257 | + bench_mp_rc_new::<1>(c, OP_COUNT); |
258 | 258 | bench_std_rc_new::<1>(c, OP_COUNT); |
259 | 259 |
|
260 | | - bench_arena_rc_drop::<1>(c, OP_COUNT); |
| 260 | + bench_mp_rc_drop::<1>(c, OP_COUNT); |
261 | 261 | bench_std_rc_drop::<1>(c, OP_COUNT); |
262 | 262 |
|
263 | | - bench_arena_rc_new::<80>(c, OP_COUNT); |
| 263 | + bench_mp_rc_new::<80>(c, OP_COUNT); |
264 | 264 | bench_std_rc_new::<80>(c, OP_COUNT); |
265 | 265 |
|
266 | | - bench_arena_rc_drop::<80>(c, OP_COUNT); |
| 266 | + bench_mp_rc_drop::<80>(c, OP_COUNT); |
267 | 267 | bench_std_rc_drop::<80>(c, OP_COUNT); |
268 | 268 |
|
269 | | - bench_arena_rc_new::<160>(c, OP_COUNT); |
| 269 | + bench_mp_rc_new::<160>(c, OP_COUNT); |
270 | 270 | bench_std_rc_new::<160>(c, OP_COUNT); |
271 | 271 |
|
272 | | - bench_arena_rc_drop::<160>(c, OP_COUNT); |
| 272 | + bench_mp_rc_drop::<160>(c, OP_COUNT); |
273 | 273 | bench_std_rc_drop::<160>(c, OP_COUNT); |
274 | 274 | } |
275 | 275 |
|
|
0 commit comments