Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

performance tool

by Alex the Serb (Monk)
on Dec 27, 2001 at 13:34 UTC ( #134573=perlquestion: print w/replies, xml ) Need Help??

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!

Replies are listed 'Best First'.
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.

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
    
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://134573]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-08-07 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?