blob: e145f580c1063e40b8ed1c4e862102dcbf384212 (
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
|
use super::*;
use test::Bencher;
const RB_SIZE: usize = 0x400;
#[bench]
fn single_item(b: &mut Bencher) {
let buf = RingBuffer::<u64>::new(RB_SIZE);
let (mut prod, mut cons) = buf.split();
prod.push_slice(&[1; RB_SIZE / 2]);
b.iter(|| {
prod.push(1).unwrap();
cons.pop().unwrap();
});
}
#[bench]
fn slice_x10(b: &mut Bencher) {
let buf = RingBuffer::<u64>::new(RB_SIZE);
let (mut prod, mut cons) = buf.split();
prod.push_slice(&[1; RB_SIZE / 2]);
let mut data = [1; 10];
b.iter(|| {
prod.push_slice(&data);
cons.pop_slice(&mut data);
});
}
#[bench]
fn slice_x100(b: &mut Bencher) {
let buf = RingBuffer::<u64>::new(RB_SIZE);
let (mut prod, mut cons) = buf.split();
prod.push_slice(&[1; RB_SIZE / 2]);
let mut data = [1; 100];
b.iter(|| {
prod.push_slice(&data);
cons.pop_slice(&mut data);
});
}
#[bench]
fn slice_x1000(b: &mut Bencher) {
let buf = RingBuffer::<u64>::new(RB_SIZE);
let (mut prod, mut cons) = buf.split();
prod.push_slice(&[1; 16]);
let mut data = [1; 1000];
b.iter(|| {
prod.push_slice(&data);
cons.pop_slice(&mut data);
});
}
|