Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > FAQ 3.6 How do I profile my Perl programs?

Reply
Thread Tools

FAQ 3.6 How do I profile my Perl programs?

 
 
PerlFAQ Server
Guest
Posts: n/a
 
      03-04-2011
This is an excerpt from the latest version perlfaq3.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

3.6: How do I profile my Perl programs?

(contributed by brian d foy, updated Fri Jul 25 12:22:26 PDT 200

The "Devel" namespace has several modules which you can use to profile
your Perl programs. The "Devel:Prof" module comes with Perl and you
can invoke it with the "-d" switch:

perl -dProf program.pl

After running your program under "DProf", you'll get a tmon.out file
with the profile data. To look at the data, you can turn it into a
human-readable report with the "dprofpp" program that comes with
"Devel:Prof".

dprofpp

You can also do the profiling and reporting in one step with the "-p"
switch to "dprofpp":

dprofpp -p program.pl

The "Devel::NYTProf" (New York Times Profiler) does both statement and
subroutine profiling. It's available from CPAN and you also invoke it
with the "-d" switch:

perl -d:NYTProf some_perl.pl

Like "DProf", it creates a database of the profile information that you
can turn into reports. The "nytprofhtml" command turns the data into an
HTML report similar to the "Devel::Cover" report:

nytprofhtml

CPAN has several other profilers that you can invoke in the same
fashion. You might also be interested in using the "Benchmark" to
measure and compare code snippets.

You can read more about profiling in *Programming Perl*, chapter 20, or
*Mastering Perl*, chapter 5.

perldebguts documents creating a custom debugger if you need to create a
special sort of profiler. brian d foy describes the process in *The Perl
Journal*, "Creating a Perl Debugger", http://www.ddj.com/184404522 , and
"Profiling in Perl" http://www.ddj.com/184404580 .

Perl.com has two interesting articles on profiling: "Profiling Perl", by
Simon Cozens, http://www.perl.com/lpt/a/850 and "Debugging and Profiling
mod_perl Applications", by Frank Wiles,
http://www.perl.com/pub/a/2006/02/09..._mod_perl.html .

Randal L. Schwartz writes about profiling in "Speeding up Your Perl
Programs" for *Unix Review*,
http://www.stonehenge.com/merlyn/UnixReview/col49.html , and "Profiling
in Template Toolkit via Overriding" for *Linux Magazine*,
http://www.stonehenge.com/merlyn/LinuxMag/col75.html .



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 04-04-2011 10:00 PM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 02-27-2011 11:00 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM



Advertisments