node-fast-string-search
node-fast-string-search copied to clipboard
Is it really faster than `String.indexOf()`?
Hello, nice work!
I tried your benchmark with different sets of inputs, a combination of short, medium and long text or search pattern, i.e.:
- short text, short search pattern,
- short text, short search pattern,
- short text, long search pattern,
- medium text, short search pattern,
- etc.
My results show that String.indexOf() is faster than this implementation. I read somewhere that the implementation of indexOf in Javascript implements the Boyer-Moore algorithm along with some tweaks based on the inputs.
I think that your test cases in the benchmark are not general enough. You are building a large string with a repeated set of characters. I generated random strings using the crypto module.
Please note that I am not criticizing your work in any way, I just wanted to share my findings after going through your code.
Thanks!