3 ms·
200ms for 180k entries sounds way too slow. Just tested on my 150k line log file and it takes about 10ms on average for various kinds of patterns with various h
by PhilipRoman 3y ago
200ms for 180k entries sounds way too slow. Just tested on my 150k line log file and it takes about 10ms on average for various kinds of patterns with various hit frequencies.
On an unrelated note, from a quick check with "strace", gnu grep seems to detect when output is redirected to /dev/null as no write syscalls are being made in that case.
- watermelon0 3y agoUnrelated note intrigued me, so I went looking in the source code; detection is here: https://git.savannah.gnu.org/cgit/grep.git/tree/src/grep.c#n2886 https://git.savannah.gnu.org/cgit/grep.git/tree/src/grep.c#n... Interesting that they would optimize for this use case.
- remram 3y agoEspecially since grep -q exists. It would never come to my mind to direct grep's output to /dev/null, I wonder how this optimization came to be?