in reply to Re: Sloooooow algo in Perl
in thread Sloooooow algo in Perl

I will hook up Time::HiRes and start timing the loops

You might want to look up Devel::Dprof instead. It's part of the core distribution, and it gives you a nice breakdown of where the time goes. In a nutshell:

perl -d:Dprof your_script # wait 160 seconds or whatever... dprofpp
(the "dprofpp" tool should be in the same path where perl was installed). To get the best use out of it, you might want to split up your code to put one or more of the inner loops into separate subroutines, to get better granularity on the timing analysis.

(While breaking things up that way, who knows... you might figure out some other way to do it -- then you can use Benchmark to compare which approach is best, in case it's not immediately obvious. :)

Replies are listed 'Best First'.
Re^3: Sloooooow algo in Perl
by QM (Parson) on Mar 27, 2005 at 13:12 UTC
    You might want to look up Devel::Dprof instead.
    For line-by-line profiling, I've found Devel::SmallProf very useful. It's used much the same way.

    # wait 160 seconds or whatever...
    Actually, I found with both Dprof and SmallProf that the wallclock time is significantly longer than the "profiled" time. For Dprof, I recall 5x; for SmallProf, more like 10x.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of