Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site tektools.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!daemon!tektools!jerryp From: jerryp@tektools.UUCP (Jerry Peek) Newsgroups: net.unix-wizards Subject: Re: Relative speed of Bourne vs. C Shells - C Shell is faster. Message-ID: <179@tektools.UUCP> Date: Fri, 29-Mar-85 11:11:42 EST Article-I.D.: tektools.179 Posted: Fri Mar 29 11:11:42 1985 Date-Received: Sun, 31-Mar-85 04:05:44 EST References: <216@sdcc12.UUCP> <12138@watmath.UUCP> <84@tekcrl.UUCP> Reply-To: jerryp@tektools.UUCP (Jerry Peek) Organization: Tektronix, Beaverton OR Lines: 39 Summary: [...getting onto a tangent...] In article <84@tekcrl.UUCP> toddb@tekcrl.UUCP (Todd Brunhoff) writes: > > I consider that a rather silly comparison since neither shell was designed > for numeric processing. You wouldn't use Fortran or C for evaluating > predicates like you would find in Prolog, etc, etc. A better solution for > your "application" (which uses about .8u and 1.2s) would be > > #!/bin/sh > awk ' > BEGIN { > x = 1; > while (x < 100) > if (x++ > 10) > print "Hi!" x > exit > }' Though this wasn't the point Todd was trying to make, it's a good place to use the magic-number business to feed the script *directly* to awk, and never start a shell *at all*. The following setup shaves the script above (about 0.4u and 0.4s) down to 0.3u and 0.2s: #! /bin/awk -f BEGIN { x = 1; while (x < 100) if (x++ > 10) print "Hi!" x exit } --Jerry Peek, UNIX Training Instructor, Tektronix, Inc. US Mail: MS 76-036, P.O. Box 500, Beaverton, OR 97077 uucp: {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp CS,ARPAnet: jerryp%tektools@tektronix.csnet Phone: 503/627-1603