[Israel.pm] Article: Optimizing Perl
moonwalker at mchsi.com
Fri Oct 29 08:08:28 PDT 2004
On Thursday 28 October 2004 4:21 am, Gabor Szabo wrote:
I timed these routines with benchmark:
These are the results:
timethis 1000000: 17 wallclock secs ( 0.91 usr + 0.37 sys = 1.28 CPU) @
print $x, $y;
timethis 1000000: 16 wallclock secs ( 0.75 usr + 0.31 sys = 1.06 CPU) @
print $x . $y;
timethis 1000000: 16 wallclock secs ( 0.97 usr + 0.29 sys = 1.26 CPU) @
Looks like print$x, $y: is the clear winner in the print routines above.
> I would not call that a nice article.
> It starts with a number of examples on how to optimise.
> Shows an example of two versions of some stupid academic code and
> later on explains why profiling is not a big deal. (later he says he
> does use profiling every time which confused me a bit)
> In short he advocates premature (micro)optimisation.
> But then actually I was not expecting anything good once I saw the
> name of the author. I have encountered a number of his books and would
> not recommend them to anyone.
> He also shows a couple of micro optimisations (such as double quotes
> single quotes ?) I have not heard this one yet. I keep hearing the
> question which is faster:
> print "$x$y";
> print $x, $y;
> print $x . $y;
> Very nice. I just encountered a piece of code that was running slowly.
> I immediately saw I could optimise it with one of the above ways and
> gain maybe as much as 10-20%.
> Or I can replace the database which was a DB file with a real SQL database
> and get a speed improvement of about x50 (50 times faster).
> Let's hear Shlomo about data structures ! :)
> Perl mailing list
> Perl at perl.org.il
More information about the Perl