Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man3 / Devel::DProf.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" 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. | will give a
.\" real vertical bar. \*(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-|\(bv\*(Tr
.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\}
.\"
.\" 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.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" 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 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
.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 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 14
\& #fOrTyTwO
\& $hz=100;
\& $XS_VERSION='DProf 19970606';
\& # 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's user time at sub entry/exit mark, in ticks
\& app's system time at sub entry/exit mark, in ticks
\& app's 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='DProf 19971213';
\& # 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;
.Ve
.PP
.Vb 20
\& 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
The lines starting with \f(CW\*(C`@\*(C'\fR mark time passed from the previous \f(CW\*(C`@\*(C'\fR
line. The lines starting with \f(CW\*(C`&\*(C'\fR introduce new subroutine \fIid\fR and
show the package and the subroutine name of this id. Lines starting
with \f(CW\*(C`+\*(C'\fR, \f(CW\*(C`\-\*(C'\fR and \f(CW\*(C`*\*(C'\fR mark entering and exit of subroutines by
\&\fIid\fRs, and \f(CW\*(C`goto &subr\*(C'\fR.
.PP
The \fIold-style\fR \f(CW\*(C`+\*(C'\fR\- and \f(CW\*(C`\-\*(C'\fR\-lines are used to mark the overhead
related to writing to profiler-output file.
.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 \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.
.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 = 'current_sub';
\& ...
\& $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 \fIskip()\fR function, for
example. See perldiag for more details.
.PP
Mail 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)