ripgrep is faster than {grep, ag, git grep, ucg, pt, sift} - Andrew Gallant's Blog
In this article I will introduce a new command line search tool, ripgrep, that combines the usability of The Silver Searcher (an ack clone) with the raw performance of GNU grep. We will attempt to do the impossible: a fair benchmark comparison between several popular code search tools. As someone who has worked on text search in Rust in their free time for the last 2.5 years, and as the author of both ripgrep and the underlying regular expression engine, I will use this opportunity to provide detailed insights into the performance of each code search tool. No benchmark will go unscrutinized! NOTE: I'm hearing reports from some people that rg isn't as fast as I've claimed on their data. I'd love to help explain what's going on, but to do that, I'll need to be able to reproduce your results. If you file an issue with something I can reproduce, I'd be happy to try and explain it. Why should you use ripgrep over any other search tool? In other words, use ripgrep if you like speed, filtering by default, fewer bugs and Unicode support. I'd like to try to convince you why you shouldn't use ripgrep. Often, this is far more revealing than reasons why I think you should use ripgrep. Despite initially not wanting to add every feature under the sun to ripgrep, over time, ripgrep has grown support for most features found in other file searching tools. This includes searching for results spanning across multiple lines, and opt-in support for PCRE2, which provides look-around and backreference support. The binary name for ripgrep is rg. Binaries for ripgrep are available for Windows, Mac and Linux. Linux binaries are static executables. Windows binaries are available either as built with MinGW (GNU) or with Microsoft Visual C (MSVC). When possible, prefer MSVC over GNU, but you'll need to have the Microsoft VC 2015 redistributable installed. If you're a Homebrew user, then you can install it like so: If you're an Archlinux user, then you can install ripgrep from the official repos: If you're a Rust programmer, ripgrep can be installed with cargo: If you'd like to build ripgrep from source, that is also easy to do. If you have a Rust nightly compiler, then you can enable optional SIMD acceleration like so, which is used in all benchmarks reported in this article. The command line usage of ripgrep doesn't differ much from other tools that perform a similar function, so you probably already know how to use ripgrep. The full details can be found in rg --help, but let's go on a whirlwind tour. Coloring works on Windows too! Colors can be controlled more granularly with the --color flag. One last thing before we get started: generally speaking, ripgrep assumes the input is reading is UTF-8. However, if ripgrep notices a file is encoded as UTF-16, then it will know how to search it. For other encodings, you'll need to explicitly specify them with the -E/--encoding flag. To recursively search the current directory, while respecting all .gitignore
Oct-12-2022, 11:37:02 GMT
- Technology: