aboutsummaryrefslogtreecommitdiffstats
path: root/benches/concat.rs
blob: 0b31ebb61baae76d9cb98d98b090807d552a02fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use criterion::{black_box, criterion_group, criterion_main, Criterion};

use edit::rope::Rope;

fn concat(buf: &[u8]) -> Rope {
    let mut r = Rope::new(&[]);
    for &b in buf.iter() {
        r = r.concat(&Rope::new(&[b]));
    }
    r
}

fn criterion_benchmark(c: &mut Criterion) {
    let bytes = vec![0; 1000];
    c.bench_function("concat asdfasdf", |b| b.iter(|| concat(black_box(&bytes))));
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);