3 ms·
Linear Searching 200MB with Ruby, Node, and Go
- jimsmart 9y agoIn Go, using strings.Index (from the standard library) will probably out-perform the naive algorithm used in the article — it's well optimised and, for that string length, will use Rabin-Karp search. - https://golang.org/src/strings/strings_amd64.go?s=720:752#L17 https://golang.org/src/strings/strings_amd64.go?s=720:752#L1... - https://en.wikipedia.org/wiki/Rabin–Karp_algorithm https://en.wikipedia.org/wiki/Rabin–Karp_algorithm One would imagine that similar algorithm implementations also exist for the other languages too.
- mattbillenstein 9y agopypy 2.7.13 ~700ms Python 2.7.13 ~63s https://gist.github.com/mattbillenstein/39f0399e842c63355c74173e34d49965 https://gist.github.com/mattbillenstein/39f0399e842c63355c74...
- mattbillenstein 9y agostring.find takes ~40ms