R. Elliott Childre 4d5a759955
Update deps for libafl (#1042)
Reduces total number of packages from 577 to 571 on building with:
`cargo +nightly build --workspace --all-features`

* ahash 0.7 -> 0.8
  * Move `AHasher::new_with_keys` to `RandomState::with_seeds` given the
    recommendation from: aHash maintainer:
    https://github.com/tkaitchuck/aHash/issues/132#issuecomment-1288207069

* bindgen: 0.61 -> 0.63

* c2rust-bitfields: 0.3 -> 0.17

* criterion: 0.3 -> 0.4

* crossterm: 0.25 -> 0.26

* dynasmrt: 1.2 -> 2

* goblin: 0.5.3 -> 0.6

* hashbrown: 0.12 -> 0.13

* nix: 0.25 -> 0.26
  * The `addr` arg of `mmap` is now of type `Option<NonZeroUsize>`
  * The `length` arg of `mmap` is now of type `NonZeroUsize`
  * Requires updating implementers to update `nix` as well

* prometheus-client: 0.18.0 -> 0.19
  * Do not box metrics
  * Gauges (a majority of the LibAFL metrics) are now i64 types so there
    is a small chance of overflow, with the u64 values that LibAFL
    tracks, but unlikely to be problematic.
 * Keep `exec_rate` as a floating point value

* serial_test: 0.8 -> 1

* typed-builder: 0.10.0 -> 0.12

* windows: 0.42.0 -> 0.44

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-02-06 12:24:42 +01:00

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);