pxi 2ec08aa82c | ||
---|---|---|
.. | ||
cmd | ||
csv | ||
internal | ||
Makefile | ||
README.md | ||
go.mod |
README.md
Go Fast Replace
An implementation in Go.
To build
make build
To run
make run
To test
make test
Conclusions
Replace
Current implementations:
bm
usesstrings.NewReplacer
which uses the Boyer–Moore algorithm.cw
uses Commentz–Walter algorithm.
Results
bm
varies a lot, but is never over 460µs.cw
is a lot slower, at around 3.5ms, but it can search for multiple patterns at once.
$ make run
./bin/corpus
Creating corpus...
./bin/pairs
Creating pairs...
./bin/replace
bm: 273.621µs
cw: 2.939254ms
Todo:
- Implement parallelism on the Commentz–Walter implementation.
- Boyer–Moore variants
- Rabin–Karp algorithm.
- Aho–Corasick algorithm.