From 491d47886be80dc561da3b371a55feaa494fe952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Mon, 20 Apr 2026 15:27:24 +0300 Subject: [PATCH 1/2] benches: update criterion, tweak code --- .gitignore | 1 + benches/Cargo.toml | 14 ++------------ benches/src/ascon.rs | 44 ++++++++++++-------------------------------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 8c754c8..8ef909b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ */target/ */*/target/ +benches/Cargo.lock diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 384e2da..2555235 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -2,10 +2,7 @@ name = "benches" version = "0.0.0" description = "Criteration benchmarks of the sponges crates" -authors = [ - "Sebastian Ramacher ", - "RustCrypto Developers", -] +authors = ["RustCrypto Developers"] edition = "2024" rust-version = "1.85" publish = false @@ -14,14 +11,7 @@ publish = false [dev-dependencies] ascon = { path = "../ascon" } -criterion = "0.4" -rand = { version = "0.8", default-features = false, features = [ - "std_rng", - "getrandom", -] } - -[features] -no_unroll = ["ascon/no_unroll"] +criterion = "0.7" [[bench]] name = "ascon" diff --git a/benches/src/ascon.rs b/benches/src/ascon.rs index 03c1cce..1a84434 100644 --- a/benches/src/ascon.rs +++ b/benches/src/ascon.rs @@ -1,44 +1,24 @@ -// Copyright 2022 Sebastian Ramacher -// SPDX-License-Identifier: Apache-2.0 OR MIT - use ascon::State; use criterion::{criterion_group, criterion_main, Criterion}; -use rand::{rngs::StdRng, RngCore, SeedableRng}; fn criterion_bench_permutation(c: &mut Criterion) { - let mut rng = StdRng::from_entropy(); - let mut state = State::new( - rng.next_u64(), - rng.next_u64(), - rng.next_u64(), - rng.next_u64(), - rng.next_u64(), - ); + let mut state = core::hint::black_box(State::new( + 0xd0764d4f4476689f, + 0x519e4174576f3791, + 0xfbe07cfb0c24ed8c, + 0xb37d9f600cd835b8, + 0xcb231c3874846a73, + )); let mut c = c.benchmark_group("Permutation"); - c.bench_function("1 round", |b| { - b.iter(|| { - state.permute_1(); - }) - }); - c.bench_function("6 rounds", |b| { - b.iter(|| { - state.permute_6(); - }) - }); + c.bench_function("1 round", |b| b.iter(|| state.permute_1())); + c.bench_function("6 rounds", |b| b.iter(|| state.permute_6())); + c.bench_function("8 rounds", |b| b.iter(|| state.permute_8())); + c.bench_function("12 rounds", |b| b.iter(|| state.permute_12())); - c.bench_function("8 rounds", |b| { - b.iter(|| { - state.permute_8(); - }) - }); + core::hint::black_box(state); - c.bench_function("12 rounds", |b| { - b.iter(|| { - state.permute_12(); - }) - }); c.finish(); } From c5ffc921dc535d687990f6e926d3b0bb492ff8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Mon, 20 Apr 2026 15:28:37 +0300 Subject: [PATCH 2/2] tweak gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8ef909b..349b62f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ target/ -*/target/ -*/*/target/ +benches/target/ benches/Cargo.lock