Relative speed of Bourne vs. C Shells - C Shell is faster.
Jerry Peek
jerryp at tektools.UUCP
Sat Mar 30 02:11:42 AEST 1985
[...getting onto a tangent...]
In article <84 at tekcrl.UUCP> toddb at 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 at tektronix.csnet
Phone: 503/627-1603
More information about the Comp.unix.wizards
mailing list