Skip to content

Commit

Permalink
Add foldhash to bench
Browse files Browse the repository at this point in the history
  • Loading branch information
ogxd committed Nov 14, 2024
1 parent 87a6d72 commit 2a93356
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ highway = "1.2.0"
seahash = "4.1.0"
metrohash = "1.0.6"
fnv = "1.0.7"
foldhash = "0.1.3"

[dev-dependencies.plotters]
version = "0.3.7"
Expand Down
4 changes: 4 additions & 0 deletions benches/quality/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ use rand::Rng;
use criterion::black_box;

fn main() {
// Passing hash functions ✅
bench_hasher_quality::<gxhash::GxBuildHasher>("GxHash");
bench_hasher_quality::<std::collections::hash_map::RandomState>("Default");
bench_hasher_quality::<twox_hash::xxh3::RandomHashBuilder64>("XxHash (XXH3)");
bench_hasher_quality::<ahash::RandomState>("AHash");
bench_hasher_quality::<t1ha::T1haBuildHasher>("T1ha");

// Not passing hash functions ❌
bench_hasher_quality::<fnv::FnvBuildHasher>("FNV-1a");
bench_hasher_quality::<foldhash::quality::RandomState>("FoldHash");
}

macro_rules! check {
Expand Down
8 changes: 7 additions & 1 deletion benches/throughput/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod result_processor;
use result_processor::*;

use std::hint::black_box;
use std::hash::Hasher;
use std::hash::{BuildHasher, Hasher};
use std::time::{Instant, Duration};
use std::alloc::{alloc, dealloc, Layout};
use std::slice;
Expand Down Expand Up @@ -47,6 +47,12 @@ fn main() {
benchmark(processor.as_mut(), slice, "XxHash (XXH3)", |data: &[u8], seed: u64| -> u64 {
twox_hash::xxh3::hash64_with_seed(data, seed)
});

// FoldHash
let foldhash_hasher: foldhash::quality::RandomState = foldhash::quality::RandomState::default();
benchmark(processor.as_mut(), slice, "FoldHash", |data: &[u8], _: i32| -> u64 {
foldhash_hasher.hash_one(data)
});

// AHash
let ahash_hasher = ahash::RandomState::with_seed(42);
Expand Down

0 comments on commit 2a93356

Please sign in to comment.