2 ms·
grep still runs a regex processor though, which I think by default is a deterministic finite-state machine. I had the impression that even when only fixed strin
by cmarschner 4y ago
grep still runs a regex processor though, which I think by default is a deterministic finite-state machine. I had the impression that even when only fixed strings are used one would still need to use -F to get to full speed. For fixed strings Boyer-Moore is the obvious choice.
- burntsushi 4y agoYou can pretty easily empirically test this and conclude that your impression is not true, at least for GNU grep. :-) $ time grep 'ZQZQZQZQZQ' OpenSubtitles2018.raw.en | wc -l 0 real 1.089 user 0.230 sys 0.858 maxmem 5 MB faults 0 $ time grep -E 'ZQZQZQZQZQ' OpenSubtitles2018.raw.en | wc -l 0 real 1.094 user 0.210 sys 0.883 maxmem 5 MB faults 0 $ time grep -F 'ZQZQZQZQZQ' OpenSubtitles2018.raw.en | wc -l 0 real 1.096 user 0.223 sys 0.872 maxmem 5 MB faults 0