From 70214e1b6f496cb5a36707dff5db0eee408b5f8e Mon Sep 17 00:00:00 2001 From: K Shiva Kiran Date: Thu, 18 Apr 2024 19:22:57 +0530 Subject: [PATCH] Added benchmark --- Cargo.toml | 12 ++++++++++-- benches/bench.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 benches/bench.rs diff --git a/Cargo.toml b/Cargo.toml index 9d0c0fc..f12b0e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 "] +authors = ["K Shiva Kiran "] 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 \ No newline at end of file +doctest = false + +[dev-dependencies] +criterion = "0.5.1" + +[[bench]] +name = "bench" +harness = false diff --git a/benches/bench.rs b/benches/bench.rs new file mode 100644 index 0000000..285c013 --- /dev/null +++ b/benches/bench.rs @@ -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);