summaryrefslogtreecommitdiffstats
path: root/third_party/rust/keccak/benches/mod.rs
blob: c080857e396a7ecfec429ca7ab3c9aa1065fc891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![feature(test)]
#![cfg_attr(feature = "simd", feature(portable_simd))]

extern crate keccak;
extern crate test;

use keccak::{f1600, f200, f400, f800};

macro_rules! impl_bench {
    ($name:ident, $fn:ident, $type:expr) => {
        #[bench]
        fn $name(b: &mut test::Bencher) {
            let mut data = [$type; 25];
            b.iter(|| $fn(&mut data));
        }
    };
}

impl_bench!(b_f200, f200, 0u8);
impl_bench!(b_f400, f400, 0u16);
impl_bench!(b_f800, f800, 0u32);
impl_bench!(b_f1600, f1600, 0u64);

#[cfg(feature = "simd")]
mod simd {
    use keccak::simd::{f1600x2, f1600x4, f1600x8, u64x2, u64x4, u64x8};

    impl_bench!(b_f1600x2, f1600x2, u64x2::splat(0));
    impl_bench!(b_f1600x4, f1600x4, u64x4::splat(0));
    impl_bench!(b_f1600x8, f1600x8, u64x8::splat(0));
}