3 ms·
Grep is really fast at that at the actual search (gnu grep at least), the gain there is mostly that "smarter" tools will ignore e.g. VCS data or binary files by
by masklinn 7y ago
Grep is really fast at that at the actual search (gnu grep at least), the gain there is mostly that "smarter" tools will ignore e.g. VCS data or binary files by default whereas grep will trawl through your PNGs and git packfiles.
- icebraining 7y agoExplanation from the original author on why GNU grep is fast: https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug... Excerpt: "The result of this is that, in the limit, GNU grep averages fewer than 3 x86 instructions executed for each input byte it actually looks at (and it skips many bytes entirely)."
- masklinn 7y agoThere's also this bit: https://ridiculousfish.com/blog/posts/old-age-and-treachery.html https://ridiculousfish.com/blog/posts/old-age-and-treachery.... However note https://news.ycombinator.com/item?id=19522987 https://news.ycombinator.com/item?id=19522987 > It does not. ripgrep does not use Boyer-Moore in most searches. > In particular, the advice in [the freebsd mailing list post] is generally out of date. although the out of date bits are really the Boyer-Moore ones: https://lobste.rs/s/ycydmd https://lobste.rs/s/ycydmd > much of Mike Haertel’s advice in this post is still good. The bits about literal scanning, avoiding searching line-by-line, and paying attention to your input handling are on the money. > But the stuff about Boyer-Moore is outdated.
- oconnor663 7y agoIf I remember that giant post of benchmarks correctly, there are some big exceptions, particularly around non-ASCII searches.