📄 devel::dprof.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Devel::DProf 3".TH Devel::DProf 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" 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 Perl code profiler.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\& perl \-d:DProf test.pl.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"The Devel::DProf package is a Perl code profiler. This will collectinformation on the execution time of a Perl script and of the subs in thatscript. This information can be used to determine which subroutines areusing the most time and which subroutines are being called most often. Thisinformation can also be used to create an execution graph of the script,showing subroutine relationships..PPTo profile a Perl script run the perl interpreter with the \fB\-d\fR debuggingswitch. 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.PPWhen the script terminates (or when the output buffer is filled) theprofiler will dump the profile information to a file called\&\fItmon.out\fR. A tool like \fIdprofpp\fR can be used to interpret theinformation which is in that profile. The following command willprint the top 15 subroutines which used the most time:.PP.Vb 1\& dprofpp.Ve.PPTo print an execution graph of the subroutines in the script use thefollowing command:.PP.Vb 1\& dprofpp \-T.Ve.PPConsult 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.PPThe first line is the magic number. The second line is the hertz value, orclock ticks, of the machine where the profile was collected. The third lineis the name and version identifier of the tool which created the profile.The fourth line is a comment. The fifth line contains three variablesholding the user time, system time, and realtime of the process while it wasbeing profiled. The sixth line indicates the beginning of the subentry/exit profile section..PPThe 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.PPWith 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})..PPNew \f(CW\*(C`$over_*\*(C'\fR values show the measured overhead of making \f(CW$over_tests\fRcalls to the profiler These values are used by the profiler tosubtract the overhead from the runtimes..PPLines starting with \f(CW\*(C`@\*(C'\fR mark the amount of time passed since theprevious \f(CW\*(C`@\*(C'\fR line. The numbers following the \f(CW\*(C`@\*(C'\fR are integer tickcounts representing user, system, and real time. Divide these numbersby the \f(CW$hz\fR value in the header to get seconds..PPLines starting with \f(CW\*(C`&\*(C'\fR map subroutine identifiers (an integer) tosubroutine packages and names. These should only occur once persubroutine..PPLines starting with \f(CW\*(C`+\*(C'\fR or \f(CW\*(C`\-\*(C'\fR mark normal entering and exit ofsubroutines. The number following is a reference to a subroutineidentifier..PPLines 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 fromthe original sub. The sequence might look like this:.PP.Vb 3\& + 5\& * 6\& \- 5.Ve.PPLines starting with \f(CW\*(C`/\*(C'\fR is like \f(CW\*(C`\-\*(C'\fR but mark where subroutines areexited by dying. Example:.PP.Vb 4\& + 5\& + 6\& / 6\& / 5.Ve.PPFinally 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 3lines are outputted when printing of the mark above actually consumedmeasurable 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 wherea replacement for \fItimes()\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..PPWith 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 manipulationof this variable may overwrite this slot, as in.PP.Vb 3\& $DB::sub = \*(Aqcurrent_sub\*(Aq;\& ...\& $addr = $DB::sub + 0;.Ve.PPwill 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 exitfrom this subroutine. Note that the first assignment above does notchange the numeric slot (it will \fImark\fR it as invalid, but will notwrite over it)..PPAnother 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 diewith the error:.PP.Vb 1\& panic: Devel::DProf inconsistent subroutine return.Ve.PPFor example, this code will break under Devel::DProf:.PP.Vb 6\& sub foo {\& last FOO;\& }\& FOO: {\& foo();\& }.Ve.PPA pattern like this is used by Test::More's \fIskip()\fR function, forexample. See perldiag for more details..PPMail bug reports and feature requests to the perl5\-porters mailing list at\&\fI<perl5\-porters@perl.org>\fR..SH "SEE ALSO".IX Header "SEE ALSO"perl, dprofpp, \fItimes\fR\|(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -