/hash-benchmark-rs

Benchmark hash implementations in Rust

Primary LanguageRust

Hash Functions Benchmark in Rust

How to run

make run

Result

Random string, key_num(10000000), key_len(100)

Op Default AHash Murmur SeaHasher
build time 441.487 12.979 462.289 141.508
std dev 283.269 259.322 274.551 294.800
collision 0 0 0 0

Increasing number

Op Default AHash Murmur SeaHasher
build time 46.265 12.492 174.967 82.611
std dev 263.976 266.246 275.889 272.080
collision 0 0 0 0

Conclusion

  • Ahash is fastest, but it doesn't guarantee fixed hash code, so it's only recommended used in memory structures.
  • Hash code generated by those hash is almost same(evenly distributed), no big difference.
  • SeaHash generate fixed hash code, and its speed is not very bad, so it's suitable for on-disk/permanent storage.
  • DefaultHash in std is pretty good, but hash code generated by it may change over rust release.

Related projects