68 lines
1.8 KiB
Rust
68 lines
1.8 KiB
Rust
use criterion::*;
|
|
use false_bottom::{FalseBottom, Fb128, Fb256, Fb512};
|
|
|
|
pub fn bench_encryption(c: &mut Criterion) {
|
|
let inp = vec![0_u8; 1_024_000];
|
|
let mut fb128 = Fb128::init(2, 2);
|
|
let mut fb256 = Fb256::init(2, 2);
|
|
let mut fb512 = Fb512::init(2, 2);
|
|
let mut group = c.benchmark_group("Encryption with 1MiB data");
|
|
group.sample_size(21);
|
|
group.throughput(Throughput::Bytes(inp.len() as u64));
|
|
group.bench_with_input(
|
|
BenchmarkId::new("128-bit encryption", 128), &inp,
|
|
|b, inp| b.iter(|| {
|
|
fb128.add(&inp)
|
|
}),
|
|
);
|
|
group.bench_with_input(
|
|
BenchmarkId::new("256-bit encryption", 256), &inp,
|
|
|b, inp| b.iter(|| {
|
|
fb256.add(&inp)
|
|
}),
|
|
);
|
|
group.bench_with_input(
|
|
BenchmarkId::new("512-bit encryption", 512), &inp,
|
|
|b, inp| b.iter(|| {
|
|
fb512.add(&inp)
|
|
}),
|
|
);
|
|
group.finish();
|
|
}
|
|
|
|
pub fn bench_decryption(c: &mut Criterion) {
|
|
let inp = vec![0_u8; 4_096_000];
|
|
let mut fb128 = Fb128::init(2, 2);
|
|
let mut fb256 = Fb256::init(2, 2);
|
|
let mut fb512 = Fb512::init(2, 2);
|
|
let key128 = fb128.add(&inp);
|
|
let key256 = fb256.add(&inp);
|
|
let key512 = fb512.add(&inp);
|
|
let mut group = c.benchmark_group("Decryption with 4MiB data");
|
|
group.sample_size(21);
|
|
group.throughput(Throughput::Bytes(inp.len() as u64));
|
|
group.bench_with_input(
|
|
BenchmarkId::new("128-bit decryption", 128), &key128,
|
|
|b, key128| b.iter(|| {
|
|
fb128.decrypt(&key128)
|
|
}),
|
|
);
|
|
group.bench_with_input(
|
|
BenchmarkId::new("256-bit decryption", 256), &key256,
|
|
|b, key256| b.iter(|| {
|
|
fb256.decrypt(&key256)
|
|
}),
|
|
);
|
|
group.bench_with_input(
|
|
BenchmarkId::new("512-bit decryption", 512), &key512,
|
|
|b, key512| b.iter(|| {
|
|
fb512.decrypt(&key512)
|
|
}),
|
|
);
|
|
group.finish();
|
|
}
|
|
|
|
criterion_group!(encryption, bench_encryption);
|
|
criterion_group!(decryption, bench_decryption);
|
|
criterion_main!(encryption, decryption);
|