false-bottom/benches/bench.rs

27 lines
652 B
Rust

use criterion::*;
use false_bottom::{FB128, FBAlgo};
pub fn bench(c: &mut Criterion) {
let inp = vec![0_u8; 4096000];
let mut fb = FB128::init(2, 2).unwrap();
let mut group = c.benchmark_group("bench-group");
let key = fb.add(&inp);
group.sample_size(21);
group.throughput(Throughput::Bytes(inp.len() as u64));
group.bench_with_input(
BenchmarkId::new("4MB null bytes encryption", 4), &inp,
|b, inp| b.iter(|| {
fb.add(&inp)
}),
);
group.bench_with_input(
BenchmarkId::new("4MB null bytes decryption", 4), &key,
|b, key| b.iter(|| {
fb.decrypt(&key)
}),
);
}
criterion_group!(benches, bench);
criterion_main!(benches);