Skip to content

Commit

Permalink
Add xxhash xxh3 mention in benchmarks (#95)
Browse files Browse the repository at this point in the history
* Add xxhash xxh3 mention in benchmarks

* Fix feature check for benchmark svg output

* Update Benchmark Results

* Print when feature hybrid is enabled

* Update Benchmark Results

* Comma separate

* Update Benchmark Results

---------

Co-authored-by: Benchmark Bot <benchmark-bot@noreply.com>
  • Loading branch information
ogxd and Benchmark Bot authored Aug 1, 2024
1 parent 913acd2 commit 5171a82
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: rustup default nightly

- name: Benchmark
run: cargo bench --bench throughput --features bench-plot hybrid
run: cargo bench --bench throughput --features bench-plot,hybrid

- uses: actions/upload-artifact@v3
with:
Expand Down
18 changes: 9 additions & 9 deletions benches/hashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ fn benchmark<T>(c: &mut Criterion, name: &str, value: T)
{
let mut group = c.benchmark_group(format!("HashSet/{}", name));

let mut set: HashSet::<T, GxBuildHasher> = gxhash::HashSet::<T>::default();
group.bench_function("GxHash", |b| {
iterate(b, &value, &mut set);
});

let mut set = HashSet::<T>::new();
group.bench_function("Default Hasher", |b| {
iterate(b, &value, &mut set);
});

let mut set: HashSet::<T, GxBuildHasher> = gxhash::HashSet::<T>::default();
group.bench_function("GxHash", |b| {
let mut set = HashSet::<T, BuildHasherDefault<xxh3::Hash64>>::default();
group.bench_function("XxHash (XXH3)", |b| {
iterate(b, &value, &mut set);
});

Expand All @@ -37,8 +42,8 @@ fn benchmark<T>(c: &mut Criterion, name: &str, value: T)
iterate(b, &value, &mut set);
});

let mut set = HashSet::<T, BuildHasherDefault<xxh3::Hash64>>::default();
group.bench_function("XxHash", |b| {
let mut set = t1ha::T1haHashSet::<T>::default();
group.bench_function("T1ha", |b| {
iterate(b, &value, &mut set);
});

Expand All @@ -47,11 +52,6 @@ fn benchmark<T>(c: &mut Criterion, name: &str, value: T)
iterate(b, &value, &mut set);
});

let mut set = t1ha::T1haHashSet::<T>::default();
group.bench_function("T1ha", |b| {
iterate(b, &value, &mut set);
});

let mut set = HashSet::<T, highway::HighwayBuildHasher>::default();
group.bench_function("HighwayHash", |b| {
iterate(b, &value, &mut set);
Expand Down
4 changes: 2 additions & 2 deletions benches/quality/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use criterion::black_box;

fn main() {
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");
bench_hasher_quality::<twox_hash::xxh3::RandomHashBuilder64>("XxHash3");
bench_hasher_quality::<std::collections::hash_map::RandomState>("Default");
bench_hasher_quality::<fnv::FnvBuildHasher>("FNV-1a");
}

Expand Down
140 changes: 70 additions & 70 deletions benches/throughput/aarch64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 19 additions & 19 deletions benches/throughput/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,52 @@ fn main() {
};

// GxHash
let gxhash_name = if cfg!(hybrid) { "gxhash-hybrid" } else { "gxhash" };
let gxhash_name = if cfg!(feature = "hybrid") { "GxHash-Hybrid" } else { "GxHash" };
benchmark(processor.as_mut(), slice, gxhash_name, |data: &[u8], seed: i64| -> u64 {
gxhash64(data, seed)
});

// XxHash (twox-hash)
benchmark(processor.as_mut(), slice, "xxhash", |data: &[u8], seed: u64| -> u64 {
benchmark(processor.as_mut(), slice, "XxHash (XXH3)", |data: &[u8], seed: u64| -> u64 {
twox_hash::xxh3::hash64_with_seed(data, seed)
});

// AHash
let ahash_hasher = ahash::RandomState::with_seeds(0, 0, 0, 0);
benchmark(processor.as_mut(), slice, "ahash", |data: &[u8], _: i32| -> u64 {
benchmark(processor.as_mut(), slice, "AHash", |data: &[u8], _: i32| -> u64 {
ahash_hasher.hash_one(data)
});

// T1ha0
benchmark(processor.as_mut(), slice, "t1ha0", |data: &[u8], seed: u64| -> u64 {
benchmark(processor.as_mut(), slice, "T1ha0", |data: &[u8], seed: u64| -> u64 {
t1ha::t1ha0(data, seed)
});

// FNV-1a
benchmark(processor.as_mut(), slice, "FNV-1a", |data: &[u8], seed: u64| -> u64 {
let mut fnv_hasher = fnv::FnvHasher::with_key(seed);
fnv_hasher.write(data);
fnv_hasher.finish()
});

// HighwayHash
benchmark(processor.as_mut(), slice, "HighwayHash", |data: &[u8], _: i32| -> u64 {
use highway::{HighwayHasher, HighwayHash};
HighwayHasher::default().hash64(data)
});

// SeaHash
benchmark(processor.as_mut(), slice, "seahash", |data: &[u8], seed: u64| -> u64 {
benchmark(processor.as_mut(), slice, "SeaHash", |data: &[u8], seed: u64| -> u64 {
seahash::hash_seeded(data, seed, 0, 0, 0)
});

// MetroHash
benchmark(processor.as_mut(), slice, "metrohash", |data: &[u8], seed: i32| -> u64 {
benchmark(processor.as_mut(), slice, "Metrohash", |data: &[u8], seed: i32| -> u64 {
let mut metrohash_hasher = metrohash::MetroHash64::with_seed(seed as u64);
metrohash_hasher.write(data);
metrohash_hasher.finish()
});

// HighwayHash
benchmark(processor.as_mut(), slice, "highwayhash", |data: &[u8], _: i32| -> u64 {
use highway::{HighwayHasher, HighwayHash};
HighwayHasher::default().hash64(data)
});

// FNV-1a
benchmark(processor.as_mut(), slice, "fnv-1a", |data: &[u8], seed: u64| -> u64 {
let mut fnv_hasher = fnv::FnvHasher::with_key(seed);
fnv_hasher.write(data);
fnv_hasher.finish()
});

processor.finish();

// Free benchmark data
Expand Down
3 changes: 2 additions & 1 deletion benches/throughput/result_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl ResultProcessor for OutputPlot {

fn finish(&self) {
let mut arch = std::env::consts::ARCH.to_string();
if cfg!(hybrid) {
if cfg!(feature = "hybrid") {
println!("Hybrid feature enabled");
arch += "-hybrid";
}
let file_name = format!("benches/throughput/{}.svg", arch);
Expand Down
Loading

0 comments on commit 5171a82

Please sign in to comment.