Re:Do You Know How Much Your Computer Can Do in a Second?
by dan-robertson on Thursday June 22, 2023 @05:49PM
(#36439552)
Grep is fast. Like obviously in this case you’re ‘just’ measuring how fast you can read from a pipe, but there are plenty of ways grep could have been implemented that would have been slower. Generally, I think grep will convert queries into a form that can be searched for reasonably efficiently (eg KMP for longer strings (bit of a guess – not sure how good it is on modern hardware), obviously no backtracking for regular expressions.
[ Parent
| on HN ]
Re:Do You Know How Much Your Computer Can Do in a Second?
by burntsushi on Thursday June 22, 2023 @06:14PM
(#36439872)
I don't think KMP has been used in any practical substring implementation in ages. At least I'm not aware of one. I believe GNU grep uses Boyer-Moore, but that's not really the key here. The key is using memchr in BM's skip loop.