Skip to content

Commit

Permalink
bench: Report throughput in AEAD benchmarks
Browse files Browse the repository at this point in the history
This makes the results directly comparable to BoringSSL and OpenSSL
  • Loading branch information
vkrasnov authored and briansmith committed Jan 26, 2024
1 parent ee5db43 commit c1e31b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bench/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ impl aead::NonceSequence for NonceSequence {
}

fn seal_in_place_separate_tag(c: &mut Criterion) {
let mut group = c.benchmark_group("aead");

let rng = SystemRandom::new();

for &(alg_name, algorithm) in ALGORITHMS {
for record_len in RECORD_LENGTHS {
c.bench_with_input(
group.throughput(criterion::Throughput::BytesDecimal(*record_len as _));
group.bench_with_input(
bench_id("seal_in_place_separate_tag", alg_name, *record_len),
record_len,
|b, record_len| {
Expand All @@ -97,11 +100,14 @@ fn seal_in_place_separate_tag(c: &mut Criterion) {
}

fn open_in_place(c: &mut Criterion) {
let mut group = c.benchmark_group("aead");

let rng = SystemRandom::new();

for &(alg_name, algorithm) in ALGORITHMS {
for record_len in RECORD_LENGTHS {
c.bench_with_input(
group.throughput(criterion::Throughput::BytesDecimal(*record_len as _));
group.bench_with_input(
bench_id("open_in_place", alg_name, *record_len),
record_len,
|b, _record_len| {
Expand Down Expand Up @@ -140,7 +146,7 @@ fn open_in_place(c: &mut Criterion) {
}

fn bench_id(func_name: &str, alg_name: &str, record_len: usize) -> BenchmarkId {
BenchmarkId::new(format!("aead::{}::{}", alg_name, func_name), record_len)
BenchmarkId::new(format!("{}::{}", alg_name, func_name), record_len)
}

criterion_group!(aead, seal_in_place_separate_tag, open_in_place);
Expand Down

0 comments on commit c1e31b8

Please sign in to comment.