// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.

#![feature(test)]

extern crate test;
extern crate ethereum_types;
extern crate keccak_hash;

use keccak_hash::{keccak, write_keccak};
use test::Bencher;

#[bench]
fn bench_keccak_256_with_empty_input(b: &mut Bencher) {
    let empty = [0u8;0];
    b.bytes = empty.len() as u64;
    b.iter(|| {
        let _out = keccak(empty);
    })
}

#[bench]
fn bench_keccak_256_with_typical_input(b: &mut Bencher) {
    let data: Vec<u8> = From::from("some medum length string with important information");
    b.bytes = data.len() as u64;
    b.iter(|| {
        let _out = keccak(&data);
    })
}

#[bench]
fn bench_keccak_256_with_large_input(b: &mut Bencher) {
    // 4096 chars
    let data: Vec<u8> = From::from("[encoded data, 4096 characters]");
    b.bytes = data.len() as u64;
    b.iter(|| {
        let _out = keccak(&data);
    })
}
