I don't see the kind of difference on my machine (G4 iBook running Mac OS X 10.5) as you do (I'm using a 30K file of all 'x's):
radar:~ datchley$ time grep "." myfile >/dev/null
real 0m0.989s
user 0m0.821s
sys 0m0.078s
radar:~ datchley$ time perl -ne '/./' myfile >/dev/null
real 0m0.020s
user 0m0.006s
sys 0m0.013s
How big is your file, what machine?
---
echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.
| [reply] [d/l] |
On my machine (an Athlon64 with amd64-freebsd) grep is always faster than perl. Using an 8MB test file:
$ time perl5.10.0 -ne '/./ and print' /boot/kernel/kernel > /dev/null
0.070u 0.015s 0:00.09 88.8% 1490+1246k 0+0io 0pf+0w
$ time grep -a '.' /boot/kernel/kernel > /dev/null
0.026u 0.000s 0:00.03 66.6% 114+1056k 0+0io 0pf+0w
| [reply] [d/l] |
Guess I'll have to ask in the Gentoo forums then. But well... aliasing grep to pcregrep removed this slowness and I can use the regexes I love. :-) | [reply] |