sed/awk, instead of Perl
Peter Boosten
peter at boosten.org
Sat Aug 23 06:32:27 UTC 2008
Walt Pawley wrote:
> At 9:59 AM +0200 8/22/08, Oliver Fromme wrote:
>
> wump$ ls -l Desktop/klog
> -rw-r--r-- 1 wump 1001 52753322 22 Aug 16:37 Desktop/klog
> wump$ time sed "s/ .*//" Desktop/klog > kadr1
>
> real 0m10.800s
> user 0m10.580s
> sys 0m0.250s
> wump$ time perl -pe 's/ .*//' Desktop/klog > kadr2
>
> real 0m0.975s
> user 0m0.700s
> sys 0m0.270s
> wump$ cmp kadr1 kadr2
> wump$
>
> Why disparity in execution speed? Beats me, but my G5's fans
> started to take off running the sed command. I don't think the
> Perl command took long enough to register thermally. Curious.
sed outputs constantly, while perl does its output at the end at once.
Try:
time awk '{print $1}' Desktop/klog > kadr3
awk also outputs at the end, however is much smaller than perl (and
therefore much quicker).
Peter
--
http://www.boosten.org
More information about the freebsd-questions
mailing list