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

Use RefCell for interior mutability of Text::lowercase() #100

Closed greyblake closed 3 years ago

greyblake commented 3 years ago

Fixes #99

Benchmark

Performance of detect seems to be improved, without any logical reason behind it:

In master:

test bench_detect        ... bench:   9,174,526 ns/iter (+/- 523,063)
test bench_detect_script ... bench:     122,001 ns/iter (+/- 11,498)

In this branch:

test bench_detect        ... bench:   8,858,362 ns/iter (+/- 418,497)
test bench_detect_script ... bench:     126,096 ns/iter (+/- 16,487)

The benchmarks are consistently reproducible.