4 ms·
Hi David. $ (for x in `seq 1 100000`; do echo 'I am a Test Vector HeLlO World '"$x"; done) > /dev/shm/krep_tmp Best of three runs shown: $ time ./kre
by geocar 2y ago
Hi David.
$ (for x in `seq 1 100000`; do echo 'I am a Test Vector HeLlO World '"$x"; done) > /dev/shm/krep_tmp
Best of three runs shown:
$ time ./krep -i hello /dev/shm/krep_tmp
Found 43721 matches
Search completed in 0.0017 seconds (2017.44 MB/s)
Search details:
- File size: 3.52 MB
- Pattern length: 5 characters
- Using AVX2 acceleration
- Case-insensitive search
real 0m0,005s
user 0m0,001s
sys 0m0,004s
$ time ./krep HeLlO /dev/shm/krep_tmp
Found 82355 matches
Search completed in 0.0014 seconds (1259.72 MB/s)
Search details:
- File size: 1.71 MB
- Pattern length: 5 characters
- Using AVX2 acceleration
- Case-sensitive search
real 0m0,004s
user 0m0,003s
sys 0m0,004s
$ time ./krep -i "HeLlO World" /dev/shm/krep_tmp
Found 99958 matches
Search completed in 0.0021 seconds (1700.54 MB/s)
Search details:
- File size: 3.52 MB
- Pattern length: 11 characters
- Using AVX2 acceleration
- Case-insensitive search
real 0m0,005s
user 0m0,002s
sys 0m0,004s
$ time ./krep "I am a Test Vector HeLlO World" /dev/shm/krep_tmp
Found 3964 matches
Search completed in 0.0149 seconds (235.83 MB/s)
Search details:
- File size: 3.52 MB
- Pattern length: 30 characters
- Using AVX2 acceleration
- Case-sensitive search
real 0m0,016s
user 0m0,015s
sys 0m0,001s
$ time ./krep -i "I am a Test Vector hello World" /dev/shm/krep_tmp
Found 3964 matches
Search completed in 0.0178 seconds (197.70 MB/s)
Search details:
- File size: 3.52 MB
- Pattern length: 30 characters
- Using AVX2 acceleration
- Case-insensitive search
real 0m0,021s
user 0m0,017s
sys 0m0,004s
Benchmark with fgrep (the first run was good enough):
$ time fgrep -ci hello /dev/shm/krep_tmp
100000
real 0m0,003s
user 0m0,003s
sys 0m0,000s
$ time fgrep -ci "I am a Test Vector hello World" /dev/shm/krep_tmp
100000
real 0m0,010s
user 0m0,009s
sys 0m0,000s
$ time fgrep -c "I am a Test Vector HeLlO World" /dev/shm/krep_tmp
100000
real 0m0,005s
user 0m0,004s
sys 0m0,001s
This is a model name: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz. There's 40gb of ram free and 10 cores doing nothing. shell is cpuset. On commit 95ed1853b561396c8a8bcbbdd115ed6273848e3f (HEAD -> main, origin/main, origin/HEAD). gcc is 13.3.0-6ubuntu2~24.04
tl;dr: krep produces obviously wrong results slower than fgrep.
- burntsushi 2y agoConsider using a bigger haystack. Your timings are so short that you're mostly just measuring the overhead of running a process. This is relevant to krep because it spawns threads to search files (I guess for files over 1MB?). This does not mean your benchmark is worthless. It just means you can't straight-forwardly generalize from it.
- globnomulous 2y agoThat's a good point, though the readme does flatly state that krep "is designed with performance as a primary goal," so the lede's generalization that it is "blazingly fast" isn't correct, despite the later, more deeply buried caveat that "Performance may vary based on hardware, file characteristics, and search pattern" (which describes all software). And the comment you answered doesn't say just that krep is "slower" than fgrep; it says krep "produces obviously wrong results" slower. Edit: and the fact that krep lacks regular-expression support means it's not a replacement for grep or meaningfully comparable with it.
- burntsushi 2y agoI try my best to interpret pithy phrases describing a project as first order approximations, rather than literal statements of truth that perfectly generalize. Pithiness is important for communicating ideas quickly, but precision and pithiness are often in tension with one another. So I adjust my expectations accordingly. Yes, I agree that the wrong results are bad. But that doesn't invalidate my point. I even went out of my way to clarify that the benchmark wasn't worthless. Benchmarking the small input case is absolutely worth it. You just can't tell much about its scaling properties when your measurement is basically "how fast does the process start and stop." Which, again, to be clear, IT MATTERS. It just probably doesn't matter as much as readers might think it matters when they see it. So treat my comment as adding helpful context for readers that aren't experts in benchmarking grep tools from someone experienced in... benchmarking grep tools. :-) (And regexes in general. See: https://github.com/BurntSushi/rebar https://github.com/BurntSushi/rebar)
- fanf2 2y ago