Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jan 2002 19:20:24 -0500
From:      parv <parv_@yahoo.com>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: any way to make efficient the awk script
Message-ID:  <20020105002024.GA83879@moo.holy.cow>
In-Reply-To: <200201042253.g04MrOP98897@lurza.secnetix.de>
References:  <20020104202751.GA82783@moo.holy.cow> <200201042253.g04MrOP98897@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
in message <200201042253.g04MrOP98897@lurza.secnetix.de>, 
wrote Oliver Fromme thusly...
>
> parv <parv_@yahoo.com> wrote:
>  > in particular, i want to know if printf() & print
>  > statements could be combined.
> 
> Yes, sure.  If you don't change OFS, then
> 
>    print foo, bar, baz;
> 
> is exactly the same as
> 
>    printf "%s %s %s\n", foo, bar, baz;

thanks oliver, that did it.


> However, I don't think it buys you much in terms of efficiency.

i was thinking that perhaps the array creation to map month name to
number might be improved.

in my unscientific test, as you said, there is no apparent increase
in efficiency; for 13 lines i get 0.010s (real).  actually, that's
90 times better than that what i had initially w/ awk|sed pipeline.

out of curiosity, i re-appended the same file (to itself) till it grew 
to 16MB; for 106496 lines, it takes about 16-19 seconds and 50% WCPU.
i am happy.


> If you are really concerned about efficiency (if you have to
> handle millions of lines), then you'd better rewrite this in
> C.

sadly, i don't know C.  yet.

-- 
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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