Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
target/
*/target/
*/*/target/
benches/target/
benches/Cargo.lock
14 changes: 2 additions & 12 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
name = "benches"
version = "0.0.0"
description = "Criteration benchmarks of the sponges crates"
authors = [
"Sebastian Ramacher <sebastian.ramacher@ait.ac.at>",
"RustCrypto Developers",
]
authors = ["RustCrypto Developers"]
edition = "2024"
rust-version = "1.85"
publish = false
Expand All @@ -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"
Expand Down
44 changes: 12 additions & 32 deletions benches/src/ascon.rs
Original file line number Diff line number Diff line change
@@ -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();
}

Expand Down
Loading