-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: add optional support for keccak-asm (#466)
* perf: add optional support for keccak-asm * fmt * fix: unmiri * chore: add bench * chore: clippy * chore: re-enable bench * chore: clippy * chore: re-exclude tests * chore: simpler casts
- Loading branch information
Showing
6 changed files
with
51 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use alloy_primitives::{keccak256, Address, B256}; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use std::hint::black_box; | ||
|
||
fn primitives(c: &mut Criterion) { | ||
let mut g = c.benchmark_group("primitives"); | ||
g.bench_function("address/checksum", |b| { | ||
let address = Address::random(); | ||
let out = &mut [0u8; 42]; | ||
b.iter(|| { | ||
let x = address.to_checksum_raw(black_box(out), None); | ||
black_box(x); | ||
}) | ||
}); | ||
g.bench_function("keccak256/32", |b| { | ||
let mut out = B256::random(); | ||
b.iter(|| { | ||
for _ in 0..10 { | ||
out = keccak256(out); | ||
} | ||
black_box(&out); | ||
}); | ||
}); | ||
g.finish(); | ||
} | ||
|
||
criterion_group!(benches, primitives); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters