Alex the Serb has asked for the wisdom of the Perl Monks concerning the following question:
hi,
is there any good Perl module or program that can show me how much of the time is spent in certain functions and classes? For now I'm using time command on Linux, but it can only show how much time was spent during execution of the whole script. And I've found out that when you've done with your script, you can ommit the line: use strict; from you code, because then the script will work 2-3 seconds faster if it have more than 100 lines. So, I'm wondering, now, if there is some tool or something that can help me to speed up and optimize things. Is there any tool or module that can make reports of how much time is spent in vital regions of the script file?
Thanks in advance!
Re: performance tool
by danger (Priest) on Dec 27, 2001 at 13:54 UTC
|
You appear to be looking for a profiling tool. Check out
Devel::DProf and Devel::SmallProf available on CPAN.
Benchmark (as pointed out by grep above) can also be
used to compare the relative efficiencies of algorithms.
| [reply] |
Re: performance tool
by grep (Monsignor) on Dec 27, 2001 at 13:38 UTC
|
Check out Benchmark.pm.
perldoc Benchmark.pm
Straight from the POD of Benchmark.pm
timethese($count, {
'Name1' => '...code1...',
'Name2' => '...code2...',
});
grep
grep> cd pub
grep> more beer
| [reply] [d/l] [select] |
Re: performance tool
by blahblahblah (Priest) on Dec 27, 2001 at 20:07 UTC
|
The Time::HiRes module can also be useful for this type of
thing. It gives you the current time in milliseconds. I've
used it before to write log files so I can tell where my
programs are spending most of their time. | [reply] |
|