diff --git a/.travis.yml b/.travis.yml index 19c6b18ef..53e552f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ script: cargo fmt -- --check; fi - cargo check --workspace --tests --benches - - cargo test --all --exclude uint --exclude fixed-hash --exclude parity-crypto + - cargo test --workspace --exclude uint --exclude fixed-hash --exclude parity-crypto - if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then cd contract-address/ && cargo test --features=external_doc && cd ..; fi diff --git a/keccak-hash/Cargo.toml b/keccak-hash/Cargo.toml index 54c1c0439..c663c66c5 100644 --- a/keccak-hash/Cargo.toml +++ b/keccak-hash/Cargo.toml @@ -19,3 +19,7 @@ criterion = "0.3.0" [features] default = ["std"] std = [] + +[[bench]] +name = "keccak_256" +harness = false diff --git a/keccak-hash/benches/keccak_256.rs b/keccak-hash/benches/keccak_256.rs index 97e9ee13d..3a28f993a 100644 --- a/keccak-hash/benches/keccak_256.rs +++ b/keccak-hash/benches/keccak_256.rs @@ -22,12 +22,26 @@ pub fn keccak_256_with_empty_input(c: &mut Criterion) { } pub fn keccak_256_with_typical_input(c: &mut Criterion) { - let data: Vec = From::from("some medium length string with important information"); - c.bench_function("keccak_256_with_typical_input", |b| { + let mut data: Vec = From::from("some medium length string with important information"); + let len = data.len(); + let mut group = c.benchmark_group("keccak_256_with_typical_input"); + group.bench_function("regular", |b| { b.iter(|| { let _out = keccak(black_box(&data)); }) }); + group.bench_function("inplace", |b| { + b.iter(|| { + keccak_hash::keccak256(black_box(&mut data[..])); + }) + }); + group.bench_function("inplace_range", |b| { + b.iter(|| { + keccak_hash::keccak256_range(black_box(&mut data[..]), 0..len); + }) + }); + + group.finish(); } pub fn keccak_256_with_large_input(c: &mut Criterion) {