From 6cda863864711d5df497494c9cb828bb32867ad5 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 21 Nov 2023 11:17:03 -0800 Subject: [PATCH] bench aead: Do Cartesian product, not zip. The `zip()` was written intending it to work like a Cartesian product, but of course `zip()` doesn't do that. Do an actual Cartesian product. --- bench/aead.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/bench/aead.rs b/bench/aead.rs index a7e0f26611..cf93b24245 100644 --- a/bench/aead.rs +++ b/bench/aead.rs @@ -72,25 +72,27 @@ impl aead::NonceSequence for NonceSequence { fn seal_in_place_separate_tag(c: &mut Criterion) { let rng = SystemRandom::new(); - for ((alg_name, algorithm), record_len) in ALGORITHMS.iter().zip(RECORD_LENGTHS.iter()) { - c.bench_with_input( - bench_id("seal_in_place_separate_tag", alg_name, *record_len), - record_len, - |b, record_len| { - let mut key_bytes = vec![0u8; algorithm.key_len()]; - rng.fill(&mut key_bytes).unwrap(); - let unbound_key = aead::UnboundKey::new(algorithm, &key_bytes).unwrap(); - let mut key = aead::SealingKey::new(unbound_key, NonceSequence::new()); + for &(alg_name, algorithm) in ALGORITHMS { + for record_len in RECORD_LENGTHS { + c.bench_with_input( + bench_id("seal_in_place_separate_tag", alg_name, *record_len), + record_len, + |b, record_len| { + let mut key_bytes = vec![0u8; algorithm.key_len()]; + rng.fill(&mut key_bytes).unwrap(); + let unbound_key = aead::UnboundKey::new(algorithm, &key_bytes).unwrap(); + let mut key = aead::SealingKey::new(unbound_key, NonceSequence::new()); - let mut in_out = vec![0u8; *record_len]; + let mut in_out = vec![0u8; *record_len]; - b.iter(|| -> Result<(), ring::error::Unspecified> { - let aad = aead::Aad::from(black_box(TLS_AD)); - let _tag = key.seal_in_place_separate_tag(aad, &mut in_out).unwrap(); - Ok(()) - }) - }, - ); + b.iter(|| -> Result<(), ring::error::Unspecified> { + let aad = aead::Aad::from(black_box(TLS_AD)); + let _tag = key.seal_in_place_separate_tag(aad, &mut in_out).unwrap(); + Ok(()) + }) + }, + ); + } } }