Re: why a.pl is faster than b.pl



On Wed, 28 Dec 2005, Jeff Pang wrote:

> Why the a.pl is faster than b.pl? I think ever the resulte should be
> opposite.Thanks.

The easiest way to answer such questions is to benchmark and profile
where the time in each script is being spent.

These two scripts are so different in composition that it isn't
immediately obvious to me how they're similar or dis-similar.

You have two approaches you can try for answering such questions:

* have two nearly identical scripts, and measure how the small
different part impacts performance.

* break each script into components and measure how long each
component takes to complete its task.

These approaches can be intermixed as needed, but it's up to you to do
the fundamental measuring of your code for yourself.

Distill the question down to something clearer -- "why is statement (or
subroutine) A faster than statement B while having the same result" --
and you may find more concrete advice from the list members.


--
Chris Devers
DO NOT LEAVE IT IS NOT REAL
.



Relevant Pages

  • Re:perl script on remote server linux
    ... Please respond to Jeff Pang ... perl script on remote server linux ...
    (perl.beginners)
  • Re: Adding text in file written in Perl
    ... I have written a Perl script that creates the dhcpd.conf and / ... wirte the other lines to hosts file then, ... Jeff Pang ...
    (perl.beginners)
  • RE: perl script on remote server linux
    ... the user with which I am executing the script is not there in sudoers file. ... perl script on remote server linux ... Please respond to Jeff Pang ...
    (perl.beginners)
  • Re: modules not found
    ... use lib qw; ... Then the script or other modules should find the installed modules correctly. ... Jeff Pang ... NetEase AntiSpam Team ...
    (perl.beginners)