Debian Codegraph @

third_party/rust/keccak/benches/mod.rs

raw
1 #![feature(test)]
2 #![cfg_attr(feature = "simd", feature(portable_simd))]
3
4 extern crate keccak;
5 extern crate test;
6
7 use keccak::{f1600, f200, f400, f800};
8
9 macro_rules! impl_bench {
10 ($name:ident, $fn:ident, $type:expr) => {
11 #[bench]
12 fn $name(b: &mut test::Bencher) {
13 let mut data = [$type; 25];
14 b.iter(|| $fn(&mut data));
15 }
16 };
17 }
18
19 impl_bench!(b_f200, f200, 0u8);
20 impl_bench!(b_f400, f400, 0u16);
21 impl_bench!(b_f800, f800, 0u32);
22 impl_bench!(b_f1600, f1600, 0u64);
23
24 #[cfg(feature = "simd")]
25 mod simd {
26 use keccak::simd::{f1600x2, f1600x4, f1600x8, u64x2, u64x4, u64x8};
27
28 impl_bench!(b_f1600x2, f1600x2, u64x2::splat(0));
29 impl_bench!(b_f1600x4, f1600x4, u64x4::splat(0));
30 impl_bench!(b_f1600x8, f1600x8, u64x8::splat(0));
31 }