diff --git a/benches/encdec.rs b/benches/encdec.rs index df2c00d..fe82426 100644 --- a/benches/encdec.rs +++ b/benches/encdec.rs @@ -1,20 +1,27 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use urbit_q::*; -fn enc(c: &mut Criterion) { +fn enc1k(c: &mut Criterion) { let bytes: Vec = (0..1024).map(|_| rand::random()).collect(); - c.bench_function("encode 1k", |b| { - b.iter(|| encode(black_box(&bytes))) - }); + c.bench_function("encode 1k", |b| b.iter(|| encode(black_box(&bytes)))); } -fn dec(c: &mut Criterion) { +fn enc8(c: &mut Criterion) { + let bytes: Vec = (0..8).map(|_| rand::random()).collect(); + c.bench_function("encode 8", |b| b.iter(|| encode(black_box(&bytes)))); +} + +fn dec1k(c: &mut Criterion) { let bytes: Vec = (0..1024).map(|_| rand::random()).collect(); let string = encode(&bytes); - c.bench_function("decode 1k", |b| { - b.iter(|| decode(black_box(&string))) - }); + c.bench_function("decode 1k", |b| b.iter(|| decode(black_box(&string)))); +} + +fn dec8(c: &mut Criterion) { + let bytes: Vec = (0..8).map(|_| rand::random()).collect(); + let string = encode(&bytes); + c.bench_function("decode 8", |b| b.iter(|| decode(black_box(&string)))); } -criterion_group!(benches, enc, dec); +criterion_group!(benches, enc1k, enc8, dec1k, dec8); criterion_main!(benches);