3 ms·
6 and 9 seconds!! Something seems off. Here's what I get (Linux, Intel Gold G6400 CPU @ 4.00GHz): $ time for i in {1..100}; do grep -cx 'a..' /usr/share/di
by asicsp 4y ago
6 and 9 seconds!! Something seems off. Here's what I get (Linux, Intel Gold G6400 CPU @ 4.00GHz):
$ time for i in {1..100}; do grep -cx 'a..' /usr/share/dict/words; done > f1
real 0m0.249s
user 0m0.207s
sys 0m0.046s
$ time for i in {1..100}; do cat /usr/share/dict/words | grep -e '^a..$' | wc -l; done > f2
real 0m0.306s
user 0m0.386s
sys 0m0.141s
Edit: probably because your word file is similar to the one in the post? I've got only 39 matching lines from a 102401 line word file.
- googlryas 4y ago235886 lines with 90 matches on whatever is shipped with macos - shasum /usr/share/dict/words = a62edf8685920f7d5a95113020631cdebd18a185 I also put each version in a separate file, so my time commands were time ~/a and time ~/b, and I let the output go to stdout Also, weirdly, the commands you provided don't print the results from the time command - I'm not sure why (I never use zsh, it's just on the computer I'm using at the moment).
- asicsp 4y agoI just tried with 662349 line file having 177 matches ( got the word file from http://app.aspell.net/create http://app.aspell.net/create). I got `0m1.327s` for just grep command and `0m1.412s` for cat+grep+wc version. I use bash, so not sure about zsh. 6+ seconds really seems off.
- planede 4y agoAFAIK GNU grep is a different beast than other grep implementations.