Artyom Pavlov 1efeff7d02
keccak: refactor to a closure-based API (#113)
The new API provides a better way for exposing support for parallel
processing in implemented backends and resolves the issue with branching
on each application of a Keccak permutation.
2026-03-06 16:07:46 +03:00

23 lines
550 B
Rust

//! keccak benchmarks
#![feature(test)]
extern crate test;
use core::hint::black_box;
use keccak::Keccak;
macro_rules! impl_bench {
($name:ident, $fn:ident, $type:expr) => {
#[bench]
fn $name(b: &mut test::Bencher) {
let mut data = black_box([0; 25]);
Keccak::new().$fn(|f| b.iter(|| black_box(f(&mut data))))
}
};
}
impl_bench!(keccak_f200, with_f200, 0u8);
impl_bench!(keccak_f400, with_f400, 0u16);
impl_bench!(keccak_f800, with_f800, 0u32);
impl_bench!(keccak_f1600, with_f1600, 0u64);