Author image Jeff Weisberg


Devel::DProfLB - tell me why my perl program runs so slowly


    perl -d:DProfLB


The Devel::DProfLB package is a Perl code profiler.

It is intended to produce output similar to, and compatible with, Devel::DProf, but be 'Less Bad'.

This will collect information on the execution time of a Perl script and of the subs in that script. This information can be used to determine which subroutines are using the most time and which subroutines are being called most often. This information can also be used to create an execution graph of the script, showing subroutine relationships.

To profile a Perl script run the perl interpreter with the -d debugging switch. The profiler uses the debugging hooks. So to profile script the following command should be used:

    perl5 -d:DProfLB

When the script terminates the profiler will dump the profile information to a file called tmon.out. A tool like dprofpp can be used to interpret the information which is in that profile. The following command will print the top 15 subroutines which used the most time:


To print an execution graph of the subroutines in the script use the following command:

    dprofpp -T

Consult the dprofpp manpage for other options.



Filename to save profile data to, default is tmon.out


Valid profiling data is not saved until the application terminates and runs this modules END{} block. Applications which cause END{} blocks not to run (such as call _exit or exec) will leave a corrupt and/or incomplete temporary data file.

On most systems, the timing data recorded by this profiler has a granularity of 0.01 second. This may or may not be precise enough for your application.

If the program being profiled contains subroutines which do not return in a normal manner (such as by throwing an exception), the timing data is estimated and may be attributed incorrectly.

Et cetera.


The standard dprofpp program blindly evals portions of the tmon.out datafile.


    Yellowstone National Park


    Jeff Weisberg -