Added benchmark

This commit is contained in:
K Shiva Kiran 2024-04-18 19:22:57 +05:30
parent 1726d45647
commit 70214e1b6f
2 changed files with 36 additions and 2 deletions

View File

@ -3,7 +3,7 @@ name = "false-bottom"
version = "0.1.0"
description = "A deniable encryption scheme"
repository = "https://codeberg.org/skran/false-bottom"
author = ["K Shiva Kiran <shiva_kr@riseup.net>"]
authors = ["K Shiva Kiran <shiva_kr@riseup.net>"]
license = "GPL-3.0-or-later"
edition = "2021"
@ -14,6 +14,14 @@ crypto-bigint = {version = "0.5.5", features = ["generic-array"]}
base64 = "0.21.7"
bincode = "1.3.3"
typenum = "1.17.0"
rayon = "1.10.0"
[lib]
doctest = false
doctest = false
[dev-dependencies]
criterion = "0.5.1"
[[bench]]
name = "bench"
harness = false

26
benches/bench.rs Normal file
View File

@ -0,0 +1,26 @@
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);