
* sort memebers * Building bolts * fixing python, feature flags * Cleanup bolts Cargo.toml * Fix tests * cleanup libafl * removed duplicate examples * Info text * reenable agpl CI * fix impl_serdeany * new fmt * Moved bolts * fix some builds * fix * fix more fixes * serdeany * no_std * Dependency cleanup * Fix docs * Docker * add python bolts bindings * no_std test fix * merge fail * typo fix * add bolts dependency to fuzzers * tiny fixes * merge fun * clippy * link no longer exists * make sure python gets rebuilt * fix pybind * doc fix * remove bolts ref * LibAFL bolts * More info * deprecation notice for launcher * fix python * cargo fmt * fix concolic * fix * clippy * fix libafl_cc * fix tutorial, clippy * fix concolic fuzzer * fix push_stage_harness fuzzer * prelude * fix testcase post-merge * mute clippy
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
//! Compare the speed of rust hash implementations
|
|
|
|
use std::hash::{BuildHasher, Hasher};
|
|
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
use libafl_bolts::rands::{Rand, StdRand};
|
|
//use xxhash_rust::const_xxh3;
|
|
use xxhash_rust::xxh3;
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
let mut rand = StdRand::with_seed(0);
|
|
let mut bench_vec: Vec<u8> = vec![];
|
|
for _ in 0..2 << 16 {
|
|
bench_vec.push(rand.below(256) as u8);
|
|
}
|
|
|
|
c.bench_function("xxh3", |b| {
|
|
b.iter(|| xxh3::xxh3_64_with_seed(black_box(&bench_vec), 0));
|
|
});
|
|
/*c.bench_function("const_xxh3", |b| {
|
|
b.iter(|| const_xxh3::xxh3_64_with_seed(black_box(&bench_vec), 0))
|
|
});*/
|
|
c.bench_function("ahash", |b| {
|
|
b.iter(|| {
|
|
let mut hasher = ahash::RandomState::with_seeds(123, 456, 789, 123).build_hasher();
|
|
hasher.write(black_box(&bench_vec));
|
|
hasher.finish();
|
|
});
|
|
});
|
|
c.bench_function("fxhash", |b| {
|
|
b.iter(|| {
|
|
let mut hasher = rustc_hash::FxHasher::default();
|
|
hasher.write(black_box(&bench_vec));
|
|
hasher.finish();
|
|
});
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|