Devel::DProfPP - Parse Devel::DProf output
Devel::DProf
use Devel::DProfPP; my $pp = Devel::DProfPP->new Devel::DProfPP->new( file => "../tmon.out", enter => sub { my ($self, $sub_name) = shift; my $topframe = ($self->stack)[-1]; print "\t" x $frame->height, $frame->sub_name; } )->parse;
This module takes the output file from Devel::DProf (typically tmon.out) and parses it. By hooking subroutines onto the enter and leave events, you can produce useful reports from the profiling data.
enter
leave
new( file => $file, enter => \&entersub_code, leave => \&leavesub_code );
Creates a new parser object. All parameters are optional. See below for more information about what the enter and leave hooks can do.
This parses the profiler output, running the enter and leave hooks, and gathering information about subroutine timings.
During the parsing run, $pp-gtstack will return a list of Devel::DProfPP::Frame objects. (See below) These can be examined for the profile timings.
$pp-gtstack
gt
Devel::DProfPP::Frame
This returns a hash of the header information, whose keys are:
The number of clock cycles per second; the times are measured in cycles and then converted into seconds later.
The version of the XS for the profiler.
The tested overhead of profiling, in user, system and real times. These are in cycles.
The number of samples that generated the above overhead; this is usually 2000. So divide over_utime by over_tests and you'll find the user time overhead required to enter a subroutine. Take this off each subroutine enter and leave event, and you'll have the "real" user time of a subroutine call. Devel::DProfPP doesn't do this for you.
over_utime
over_tests
Devel::DProfPP
The user, system and real times (in cycles) for the whole program run.
The enter and leave hooks are called every time a subroutine is, predictable, entered or left. In each case, the parser and name of the subroutine are passed in as parameters to the hook, and everything else can be accessed through the parser object and the stack.
The following methods are available on a Devel::DProfPP::Frame object:
These return the current execution time for a stack frame individually, for the stack frame and all of its descendants, and for all instances of this code.
These times are given in seconds, but DO NOT include compensation for subroutine enter/leave overheads. If you want to compensate for these, subtract the appropriate overhead value from $pp->header.
$pp->header
The height of this stack frame - 1 for the first subroutine call on the stack, 2 for the second, and so on.
The fully qualified name of this subroutine.
Understanding how dprofpp's overhead compensation code works is Not Easy and has meant that I haven't tried to apply overhead compensation in this module. All the data's there if you want to do it yourself. The numbers produced by Devel::DProf are pseudorandom anyway, so this omission should't make any real difference.
dprofpp
Simon Cozens, simon@cpan.org
simon@cpan.org
You may distribute this module under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Devel::DProfPP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::DProfPP
CPAN shell
perl -MCPAN -e shell install Devel::DProfPP
For more information on module installation, please visit the detailed CPAN module installation guide.