Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Slower in numerical calculation than awk? Message-ID: <1991Feb04.131711.369@convex.com> Date: 4 Feb 91 13:17:11 GMT References: <9102040846.AA17752@acf4.NYU.EDU> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 36 Nntp-Posting-Host: pixel.convex.com From the keyboard of lixj@acf4.NYU.EDU (Xiaojian Li): :I write small awk and perl program, and to my dismay, awk is almost :twice as fast as perl, That depends. See below. :#!/bin/awk -f :BEGIN { x = 1.0 : for(i=0;i<100000;++i) x += i :} :END { print x } :I notice that perl gives more accurate result. Is this higher precision :which causes slowing down? In what precision perls does math? Perl uses double precision math; old awk, at least, used single precision math. Here are my numbers (5-run averages) from a Convex C-220: awk: 7.4u gawk: 7.5u nawk: 5.9u perl: 5.9u So it would appear that it varies by architecture. One anomaly in my timings is that they all took negligle system time, except for gawk, which consistently took 8.7 system time!!! Maybe a Convex is just optimized for perl. :-) [Or double precision math, which would be easier to believe.] --tom -- "Still waiting to read alt.fan.dan-bernstein using DBWM, Dan's own AI window manager, which argues with you 10 weeks before resizing your window." ### And now for the question of the month: How do you spell relief? Answer: U=brnstnd@kramden.acf.nyu.edu; echo "/From: $U/h:j" >>~/News/KILL; expire -f $U