This project is an attempt to benchmark the speed of some hash algorithms available in Elixir.
| benchmarks/output | Add more functions | |
| lib | Add more functions | |
| test | Remove tests | |
| .formatter.exs | First commit | |
| .gitignore | First commit | |
| LICENSE | First commit | |
| mix.exs | First commit | |
| mix.lock | First commit | |
| README.md | Add more functions | |
HashBenchmark
This project is an attempt to benchmark the speed of some hash algorithms available in Elixir.
My goal is to find the fastest hash algorithm/implementation in elixir to use it in Etaweb to hash the page contents.
So the main criteria here are fast execution speed and low memory usage.
Installation
- Install dependencies with
mix deps.get - Run
iex -S mix - Use any function available in the
HashBenchmarkmodule
Example
The results here are real results I get on my computer. I also get similar results using the benchee_benchmark function.
xxh3 seems to be the fastest of all.
I don't know if the fact that it's an Erlang NIF of a Rust implementation of XXH3 can skew the benchmark results somehow, especially for the memory usage which seems unrealisticly low.
iex> HashBenchmark.timer_benchmark()
[
{"xxh3 64", 0.0001},
{"xxh3 128", 0.0001},
{"crypto.hash sha1", 0.0006},
{"crypto.hash md5", 0.0014},
{"murmur x86_32", 0.0274},
{"murmur x86_128", 0.0297},
{"murmur x64_128", 0.0637},
{"xxhash 32", 0.1058},
{"xxhash 64", 0.1089}
]
Benchee results are available here