.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DProf 3pm" .TH DProf 3pm "2020-11-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Devel::DProf \- a DEPRECATED Perl code profiler .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& perl \-d:DProf test.pl .Ve .SH "ACHTUNG!" .IX Header "ACHTUNG!" \&\f(CW\*(C`Devel::DProf\*(C'\fR is \fB\s-1DEPRECATED\s0\fR and will be removed from a future version of Perl. We strongly recommend that you install and use Devel::NYTProf instead, as it offers significantly improved profiling and reporting. .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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. .PP To profile a Perl script run the perl interpreter with the \fB\-d\fR debugging switch. The profiler uses the debugging hooks. So to profile script \&\fItest.pl\fR the following command should be used: .PP .Vb 1 \& perl \-d:DProf test.pl .Ve .PP When the script terminates (or when the output buffer is filled) the profiler will dump the profile information to a file called \&\fItmon.out\fR. A tool like \fIdprofpp\fR 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: .PP .Vb 1 \& dprofpp .Ve .PP To print an execution graph of the subroutines in the script use the following command: .PP .Vb 1 \& dprofpp \-T .Ve .PP Consult dprofpp for other options. .SH "PROFILE FORMAT" .IX Header "PROFILE FORMAT" The old profile is a text file which looks like this: .PP .Vb 10 \& #fOrTyTwO \& $hz=100; \& $XS_VERSION=\*(AqDProf 19970606\*(Aq; \& # All values are given in HZ \& $rrun_utime=2; $rrun_stime=0; $rrun_rtime=7 \& PART2 \& + 26 28 566822884 DynaLoader::import \& \- 26 28 566822884 DynaLoader::import \& + 27 28 566822885 main::bar \& \- 27 28 566822886 main::bar \& + 27 28 566822886 main::baz \& + 27 28 566822887 main::bar \& \- 27 28 566822888 main::bar \& [....] .Ve .PP The first line is the magic number. The second line is the hertz value, or clock ticks, of the machine where the profile was collected. The third line is the name and version identifier of the tool which created the profile. The fourth line is a comment. The fifth line contains three variables holding the user time, system time, and realtime of the process while it was being profiled. The sixth line indicates the beginning of the sub entry/exit profile section. .PP The columns in \fB\s-1PART2\s0\fR are: .PP .Vb 5 \& sub entry(+)/exit(\-) mark \& app\*(Aqs user time at sub entry/exit mark, in ticks \& app\*(Aqs system time at sub entry/exit mark, in ticks \& app\*(Aqs realtime at sub entry/exit mark, in ticks \& fully\-qualified sub name, when possible .Ve .PP With newer perls another format is used, which may look like this: .PP .Vb 8 \& #fOrTyTwO \& $hz=10000; \& $XS_VERSION=\*(AqDProf 19971213\*(Aq; \& # All values are given in HZ \& $over_utime=5917; $over_stime=0; $over_rtime=5917; \& $over_tests=10000; \& $rrun_utime=1284; $rrun_stime=0; $rrun_rtime=1284; \& $total_marks=6; \& \& PART2 \& @ 406 0 406 \& & 2 main bar \& + 2 \& @ 456 0 456 \& \- 2 \& @ 1 0 1 \& & 3 main baz \& + 3 \& @ 141 0 141 \& + 2 \& @ 141 0 141 \& \- 2 \& @ 1 0 1 \& & 4 main foo \& + 4 \& @ 142 0 142 \& + & Devel::DProf::write \& @ 5 0 5 \& \- & Devel::DProf::write .Ve .PP (with high value of \f(CW$ENV\fR{\s-1PERL_DPROF_TICKS\s0}). .PP New \f(CW\*(C`$over_*\*(C'\fR values show the measured overhead of making \f(CW$over_tests\fR calls to the profiler These values are used by the profiler to subtract the overhead from the runtimes. .PP Lines starting with \f(CW\*(C`@\*(C'\fR mark the amount of time passed since the previous \f(CW\*(C`@\*(C'\fR line. The numbers following the \f(CW\*(C`@\*(C'\fR are integer tick counts representing user, system, and real time. Divide these numbers by the \f(CW$hz\fR value in the header to get seconds. .PP Lines starting with \f(CW\*(C`&\*(C'\fR map subroutine identifiers (an integer) to subroutine packages and names. These should only occur once per subroutine. .PP Lines starting with \f(CW\*(C`+\*(C'\fR or \f(CW\*(C`\-\*(C'\fR mark normal entering and exit of subroutines. The number following is a reference to a subroutine identifier. .PP Lines starting with \f(CW\*(C`*\*(C'\fR mark where subroutines are entered by \f(CW\*(C`goto &subr\*(C'\fR, but note that the return will still be marked as coming from the original sub. The sequence might look like this: .PP .Vb 3 \& + 5 \& * 6 \& \- 5 .Ve .PP Lines starting with \f(CW\*(C`/\*(C'\fR is like \f(CW\*(C`\-\*(C'\fR but mark where subroutines are exited by dying. Example: .PP .Vb 4 \& + 5 \& + 6 \& / 6 \& / 5 .Ve .PP Finally you might find \f(CW\*(C`@\*(C'\fR time stamp marks surrounded by \f(CW\*(C`+ & Devel::DProf::write\*(C'\fR and \f(CW\*(C`\- & Devel::DProf::write\*(C'\fR lines. These 3 lines are outputted when printing of the mark above actually consumed measurable time. .SH "AUTOLOAD" .IX Header "AUTOLOAD" When Devel::DProf finds a call to an \f(CW&AUTOLOAD\fR subroutine it looks at the \&\f(CW$AUTOLOAD\fR variable to find the real name of the sub being called. See \&\*(L"Autoloading\*(R" in perlsub. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" \&\f(CW\*(C`PERL_DPROF_BUFFER\*(C'\fR sets size of output buffer in words. Defaults to 2**14. .PP \&\f(CW\*(C`PERL_DPROF_TICKS\*(C'\fR sets number of ticks per second on some systems where a replacement for \fBtimes()\fR is used. Defaults to the value of \f(CW\*(C`HZ\*(C'\fR macro. .PP \&\f(CW\*(C`PERL_DPROF_OUT_FILE_NAME\*(C'\fR sets the name of the output file. If not set, defaults to tmon.out. .SH "BUGS" .IX Header "BUGS" Builtin functions cannot be measured by Devel::DProf. .PP With a newer Perl DProf relies on the fact that the numeric slot of \&\f(CW$DB::sub\fR contains an address of a subroutine. Excessive manipulation of this variable may overwrite this slot, as in .PP .Vb 3 \& $DB::sub = \*(Aqcurrent_sub\*(Aq; \& ... \& $addr = $DB::sub + 0; .Ve .PP will set this numeric slot to numeric value of the string \&\f(CW\*(C`current_sub\*(C'\fR, i.e., to \f(CW0\fR. This will cause a segfault on the exit from this subroutine. Note that the first assignment above does not change the numeric slot (it will \fImark\fR it as invalid, but will not write over it). .PP Another problem is that if a subroutine exits using goto(\s-1LABEL\s0), last(\s-1LABEL\s0) or next(\s-1LABEL\s0) then perl may crash or Devel::DProf will die with the error: .PP .Vb 1 \& panic: Devel::DProf inconsistent subroutine return .Ve .PP For example, this code will break under Devel::DProf: .PP .Vb 6 \& sub foo { \& last FOO; \& } \& FOO: { \& foo(); \& } .Ve .PP A pattern like this is used by Test::More's \fBskip()\fR function, for example. See perldiag for more details. .SH "SEE ALSO" .IX Header "SEE ALSO" perl, dprofpp, \fBtimes\fR\|(2)