Closed DavidVentura closed 4 months ago
Hi, thank you for your pull request. I had a similar need and added is_prefix()
which I now regret because it can be achieved with the iterator-based searches available in v0.3.0 of trie-rs. I added your benchmark here. Basically, we can now just check to see if the iterator is empty or not.
assert!(trie.common_prefix_search::<Vec<u8>, _>("すしをにぎる").next().is_some());
Here are the results using the above code. They are thankfully comparable to yours.
Benchmarking [1d4d686] Trie::common_prefix_match() 100 times
Benchmarking [1d4d686] Trie::common_prefix_match() 100 times: Warming up for 1.0000 s
Benchmarking [1d4d686] Trie::common_prefix_match() 100 times: Collecting 10 samples in estimated 5.0414 s (5995 iterations)
Benchmarking [1d4d686] Trie::common_prefix_match() 100 times: Analyzing
[1d4d686] Trie::common_prefix_match() 100 times
time: [823.13 us 828.41 us 837.42 us]
I hope that's satisfactory for you.
Hey! Running this code instead of
common_prefix_search.is_empty()
is ~18% faster for my use case (which is matching a trie with \~3500 items, of 5\~40 chars eachNot sure if it's worth adding to the crate though..
Running the benchmark on my pc,