Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Slower in numerical calculation than awk? Message-ID: <11301@jpl-devvax.JPL.NASA.GOV> Date: 5 Feb 91 01:14:20 GMT References: <2540004@acf4.NYU.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 19 In article <2540004@acf4.NYU.EDU> lixj@acf4.NYU.EDU (Xiaojian Li) writes: : I write small awk and perl program, and to my dismay, awk is almost : twice as fast as perl, : [examples deleted] : : 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, but so does awk. You're just running afoul of awk's default output format. The primary reason Perl is slower in numerics is simply that I've never put much effort into optimizing them. As the man page says right up front, Perl is optimized for text processing. C has to be good for something, after all... Someday I hope to switch to something more like threaded code, and if I do, numerics will be much faster. Larry