Very nice. Not only fast, but feels modern.
Tried it out on a 3.5GB JSON file:
# rg
rg erzg4 k.json > /dev/null 1.80s user 2.54s system 53% cpu 8.053 total
# rg with 4 threads
rg -j4 erzg4 k.json > /dev/null 1.76s user 1.29s system 99% cpu 3.059 total
# OS X grep
grep erzg4 k.json > /dev/null 60.62s user 0.96s system 99% cpu 1:01.75 total
# GNU Grep
ggrep erzg4 k.json > /dev/null 1.96s user 1.43s system 88% cpu 2.691 total
GNU Grep wins, but it's pretty crusty, especially with regards to its output (even with colourization).
My guess is that since you ran `rg` first, the file wasn't in memory, and you ended up benchmarking disk IO. (Notice the sys time decrease from your first run to the second run.) Subsequent commands then run faster with the file already in memory.
This is one of many reasons why assembling the benchmarks in my blog post was so difficult. For example, on every command I benchmarked, I ran them 3 times for "warmup" and didn't record any measurements. I then ran them another 10 times in which I recorded them. You can see the raw output here: https://github.com/BurntSushi/ripgrep/blob/master/benchsuite...
In any case, on my underpowered Mac, here are some results on a 1.2 GB file (notice how much the time fluctuates until its fully in cache):
And now for rg:
Oh! And check this out, on a Mac, not using a memory map for single files is faster. My goodness---memory map performance is all over the place.
If I do this on my Linux machine on the same file, I get timings of 0.275s for rg, 0.398s for rg with no memory maps (opposite direction for Mac) and 0.708s for GNU grep (v 2.25).
Benchmarks are fun, eh?
I ran each test four times and picked the best result — not my first rodeo — but for the first result I picked the wrong time from my output, which obviously didn't make use of the cache. Here's it again, complete result, added --no-mmap:
Sounds like "alias rg=rg --no-mmap" is a good idea on a Mac.
Wow. Those are awesome results, thank you.
> Sounds like "alias rg=rg --no-mmap" is a good idea on a Mac.
I will fix that in ripgrep proper by making --no-mmap the default on Mac. :-) It should be an easy one to knock off: https://github.com/BurntSushi/ripgrep/issues/36
> not my first rodeo
Right, sorry about that. :-) Just had to cover all my bases!
(Also, `-j` on a single file won't do anything, and ripgrep should try to use multiple threads by default when searching multiple files.)
I suspected that -j wouldn't do anything on a single file. For three large (6.5GB in total) files I'm getting good performance, about 1.6x of what GNU Grep does, best case.