diff --git a/.gitignore b/.gitignore index 8c754c8..349b62f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ target/ -*/target/ -*/*/target/ +benches/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(); }