Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Aug 2008 08:32:22 +0200
From:      Peter Boosten <peter@boosten.org>
To:        Walt Pawley <walt@wump.org>
Cc:        Oliver Fromme <olli@lurza.secnetix.de>, freebsd-questions@FreeBSD.ORG
Subject:   Re: sed/awk, instead of Perl
Message-ID:  <48AFAEF6.7090800@boosten.org>
In-Reply-To: <p0624080cc4d504c10465@[10.0.0.10]>
References:  <200808220759.m7M7xuh0047625@lurza.secnetix.de> <p0624080cc4d504c10465@[10.0.0.10]>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48AFAEF6.7090800>