Java Mailing List Archive

http://www.apache-httpd.com/

Home » modperl.perl »

A great new profiler which works with mod_perl - Devel::NYTProf

Clinton Gormley

2008-07-18


Author LoginPost Reply
Hi all

For those of you who have struggled with various Devel::*Prof modules, I
thought I'd let you know about Devel::NYTProf version 2, which was
recently released.

Released by Tim Bunce (of DBI fame), this profiler is a major step
forward. It:

- profiles your code by line, sub or block

- provides exclusive and inclusive times (eg the time
 spent in the code in THIS sub, vs the time spent in the
 code CALLED BY this sub)

- calculates accurate times

- produces an easy to understand HTML report, with issues
 highlighted

- works in mod_perl - flawlessly!

You can see:
- an example : http://blog.timbunce.org/2008/07/15/nytprof-v2-a-major-advance-in-perl-profilers/
- the background story : http://blog.timbunce.org/2008/07/16/nytprof-v2-the-background-story/
- the module itself : http://search.cpan.org/~timb/Devel-NYTProf-2.01/lib/Devel/NYTProf.pm

Using it in mod_perl is as easy as adding this to your httpd.conf
(before you load any other Perl modules):

 PerlModule Devel::NYTProf::Apache

It is worth starting apache in single process mode otherwise it writes
to multiple log files:
 apachectl -X

Once you've finished using your code (in order to generate stats), you
can generate the reports with:

 nytprofhtml -f /tmp/nytprof.$PID.out

If you've got your Perl modules in some directory other than the
compiled in @INC, you can use:

  nytprofhtml -f /tmp/nytprof.$PID.out -lib /path/to/libs

I use a framework which autogenerates a number of classes, so I had to
edit nytprofhtml to add a few lines in order to initialise my framework
before running the report.

Try this out - it is super easy, and very very useful

many thanks to the authors

Clint

©2008 apache-httpd.com - Jax Systems, LLC, U.S.A.