1
use criterion::{Criterion, Throughput};
2

            
3
mod bonsai;
4

            
5
#[cfg(feature = "redis")]
6
mod redis;
7

            
8
1
pub fn benches(c: &mut Criterion) {
9
1
    write_blobs(c);
10
1
    read_blobs(c);
11
1
    increment(c);
12
1
}
13

            
14
1
pub fn write_blobs(c: &mut Criterion) {
15
1
    let mut group = c.benchmark_group("set-bytes");
16

            
17
4
    for blob_size in [64, 1024, 1024 * 1024, 1024 * 1024 * 8] {
18
4
        group.throughput(Throughput::Bytes(blob_size));
19
4

            
20
4
        let blob = vec![42; blob_size as usize];
21
4

            
22
4
        bonsai::write_blobs(&mut group, &blob);
23
4

            
24
4
        #[cfg(feature = "redis")]
25
4
        redis::write_blobs(&mut group, &blob);
26
4
    }
27
1
}
28

            
29
1
pub fn read_blobs(c: &mut Criterion) {
30
1
    let mut group = c.benchmark_group("get-bytes");
31

            
32
4
    for blob_size in [64, 1024, 1024 * 1024, 1024 * 1024 * 8] {
33
4
        group.throughput(Throughput::Bytes(blob_size));
34
4

            
35
4
        let blob = vec![42; blob_size as usize];
36
4

            
37
4
        bonsai::read_blobs(&mut group, &blob);
38
4

            
39
4
        #[cfg(feature = "redis")]
40
4
        redis::read_blobs(&mut group, &blob);
41
4
    }
42
1
}
43

            
44
1
pub fn increment(c: &mut Criterion) {
45
1
    let mut group = c.benchmark_group("increment");
46
1
    bonsai::increment(&mut group);
47
1

            
48
1
    #[cfg(feature = "redis")]
49
1
    redis::increment(&mut group);
50
1
}