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

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

am 18.07.2008 12:40:23 von Clinton Gormley

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-advan ce-in-perl-profilers/
- the background story : http://blog.timbunce.org/2008/07/16/nytprof-v2-the-backgroun d-story/
- the module itself : http://search.cpan.org/~timb/Devel-NYTProf-2.01/lib/Devel/NY TProf.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