Profiling Perl code with NYTProf

The absolute best way to profile Perl code is to use Devel::NYTProf.

Step 1. Install it, because it’s not part of the standard distribution (it should be). It’s called Devel:NYTProf, and is in ActiveState’s ppm as well as the more standard cpan.

Step 2. Use it

perl -d:NYTProf <command line to run your program>
nytprofhtml --open

This will give you a nice HTML-based profile of the execution of your program. Among the notable features are a treemap and a number of ways to drill down into the hotspots. It will even generate DOT files for rendering in Graphviz, although these are not always useful.

The perldoc on CPAN is here: Devel::NYTProf.

I’ll put a real profile up soon of one of my programs, but for now here’s an example of one that I found in a Google search: C:/lo/libo-master/solenv/bin/

Here is a post by Tim Bunce on how the updated NYTProf came into existence: NYTProf v2 – the background story. And there’s a 2008 screen cast. And there is a blog posting on the latest version.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>