Wednesday, August 29, 2007

Devel::DProf

The Devel::DProf package is a Perl code profiler. 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.

So to profile script test.pl the following command should be used:

perl -d:DProf test.pl

When the script terminates (or when the output buffer is filled) 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.
dprofpp

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

No comments: