From owner-freebsd-questions Fri Jan 4 16:19:43 2002 Delivered-To: freebsd-questions@freebsd.org Received: from gull.prod.itd.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by hub.freebsd.org (Postfix) with ESMTP id 8BE4B37B421 for ; Fri, 4 Jan 2002 16:19:36 -0800 (PST) Received: from sdn-ar-007dcwashp255.dialsprint.net ([63.178.90.145] helo=moo.holy.cow) by gull.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16MeYg-0000C3-00 for freebsd-questions@FreeBSD.ORG; Fri, 04 Jan 2002 16:19:35 -0800 Received: by moo.holy.cow (Postfix, from userid 1001) id D9AC350E48; Fri, 4 Jan 2002 19:20:24 -0500 (EST) Date: Fri, 4 Jan 2002 19:20:24 -0500 From: parv To: freebsd-questions@FreeBSD.ORG Subject: Re: any way to make efficient the awk script Message-ID: <20020105002024.GA83879@moo.holy.cow> Mail-Followup-To: freebsd-questions@FreeBSD.ORG References: <20020104202751.GA82783@moo.holy.cow> <200201042253.g04MrOP98897@lurza.secnetix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200201042253.g04MrOP98897@lurza.secnetix.de> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG in message <200201042253.g04MrOP98897@lurza.secnetix.de>, wrote Oliver Fromme thusly... > > parv 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