Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions keccak-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ criterion = "0.3.0"
[features]
default = ["std"]
std = []

[[bench]]
name = "keccak_256"
harness = false
20 changes: 14 additions & 6 deletions keccak-hash/benches/keccak_256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ pub fn keccak_256_with_empty_input(c: &mut Criterion) {
}

pub fn keccak_256_with_typical_input(c: &mut Criterion) {
let data: Vec<u8> = From::from("some medium length string with important information");
c.bench_function("keccak_256_with_typical_input", |b| {
b.iter(|| {
let _out = keccak(black_box(&data));
})
});
let mut data: Vec<u8> = 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) {
Expand Down