greyblake / whatlang-rs

Natural language detection library for Rust. Try demo online: https://whatlang.org/
https://whatlang.org/
MIT License
966 stars 108 forks source link

Replace Fnv hash with hashbrown #25

Closed greyblake closed 5 years ago

greyblake commented 5 years ago

Benchmarks:

Current fnv hasher:

running 2 tests
test bench_detect        ... bench:  24,701,919 ns/iter (+/- 2,825,460)
test bench_detect_script ... bench:     260,610 ns/iter (+/- 50,405)

Hashbrown hasher:

running 2 tests
test bench_detect        ... bench:  17,802,449 ns/iter (+/- 528,879)
test bench_detect_script ... bench:     266,517 ns/iter (+/- 10,377)

So it looks like with hashbrown the detection algorithm works ~28% faster than with fnv hasher.