greyblake / whatlang-rs

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

Main dependencies upgrades with more inlines #105

Closed jqnatividad closed 2 years ago

jqnatividad commented 2 years ago

Out of curiosity @greyblake, I gave it another go and upgraded hashmap and enum-map to the latest releases, and left the dev-dependencies alone.

After sprinkling more #[inline]s, the performance is a bit better.

running 2 tests
test bench_detect        ... bench:   8,508,715 ns/iter (+/- 571,452)
test bench_detect_script ... bench:     238,753 ns/iter (+/- 17,187)

running 2 tests
test bench_detect        ... bench:   8,378,025 ns/iter (+/- 856,485)
test bench_detect_script ... bench:     237,377 ns/iter (+/- 12,368)

running 2 tests
test bench_detect        ... bench:   8,408,746 ns/iter (+/- 738,716)
test bench_detect_script ... bench:     236,423 ns/iter (+/- 44,616)

Creating this PR just in case you want to bump the main dependencies to the latest maintained releases without the huge performance regression.

greyblake commented 2 years ago

Before

test bench_detect        ... bench:   9,065,607 ns/iter (+/- 303,908)
test bench_detect_script ... bench:     113,341 ns/iter (+/- 6,817)

test bench_detect        ... bench:   8,944,207 ns/iter (+/- 315,354)
test bench_detect_script ... bench:     113,169 ns/iter (+/- 5,634)

test bench_detect        ... bench:   9,046,893 ns/iter (+/- 284,733)
test bench_detect_script ... bench:     111,744 ns/iter (+/- 13,799)

After

test bench_detect        ... bench:   8,350,379 ns/iter (+/- 213,098)
test bench_detect_script ... bench:     106,073 ns/iter (+/- 22,040)

test bench_detect        ... bench:   8,382,447 ns/iter (+/- 279,420)
test bench_detect_script ... bench:     109,724 ns/iter (+/- 9,798)

test bench_detect        ... bench:   8,382,447 ns/iter (+/- 279,420)
test bench_detect_script ... bench:     109,724 ns/iter (+/- 9,798)

What makes ~6.8% performance improvement for bench_detect.

@jqnatividad Thanks!