4 ms·
> There's not much you can add to general purpose text search to make it faster Oh I beg to differ! The blog post goes into this. Here's a simple demonstration
by burntsushi 3y ago
> There's not much you can add to general purpose text search to make it faster
Oh I beg to differ! The blog post goes into this. Here's a simple demonstration using ripgrep 14:
$ ls -l full.txt
-rw-rw-r-- 1 andrew users 13113340782 Sep 29 12:30 full.txt
$ time rg -c --no-mmap 'Clipton' full.txt
294
real 1.419
user 0.539
sys 0.879
maxmem 15 MB
faults 0
$ time LC_ALL=C grep -c 'Clipton' full.txt
294
real 6.911
user 6.078
sys 0.829
maxmem 15 MB
faults 0
$ time rg -c --no-mmap 'DMZ|Clipton' full.txt
1070
real 1.643
user 0.747
sys 0.894
maxmem 15 MB
faults 0
$ time LC_ALL=C grep -E -c 'DMZ|Clipton' full.txt
1070
real 8.317
user 7.384
sys 0.930
maxmem 15 MB
faults 0
No memory maps. No multi-threading. No filtering. No fancy regex engine features or reducing expressiveness. No locales. No UTF-8. No UTF-16. Just a simple literal and a simple alternation of literals. It's just better algorithms.
Also, you can disable ripgrep's opinions with `-uuu`. It's not designed to just be for code searching. You can use it for normal grepping too. It will even automatically revert to the standard grep line format in shell pipelines.