home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _4c836a276d94365965ef351662401667 < prev    next >
Text File  |  2000-03-23  |  8KB  |  195 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Devel::DProf - a Perl code profiler</TITLE>
  5. <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> Devel::DProf - a Perl code profiler</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#profile format">PROFILE FORMAT</A></LI>
  26.     <LI><A HREF="#autoload">AUTOLOAD</A></LI>
  27.     <LI><A HREF="#environment">ENVIRONMENT</A></LI>
  28.     <LI><A HREF="#bugs">BUGS</A></LI>
  29.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  30. </UL>
  31. <!-- INDEX END -->
  32.  
  33. <HR>
  34. <P>
  35. <H1><A NAME="name">NAME</A></H1>
  36. <P>Devel::DProf - a Perl code profiler</P>
  37. <P>
  38. <HR>
  39. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  40. <UL>
  41. <LI>Linux</LI>
  42. <LI>Solaris</LI>
  43. <LI>Windows</LI>
  44. </UL>
  45. <HR>
  46. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  47. <PRE>
  48.         perl5 -d:DProf test.pl</PRE>
  49. <P>
  50. <HR>
  51. <H1><A NAME="description">DESCRIPTION</A></H1>
  52. <P>The Devel::DProf package is a Perl code profiler.  This will collect
  53. information on the execution time of a Perl script and of the subs in that
  54. script.  This information can be used to determine which subroutines are
  55. using the most time and which subroutines are being called most often.  This
  56. information can also be used to create an execution graph of the script,
  57. showing subroutine relationships.</P>
  58. <P>To profile a Perl script run the perl interpreter with the <STRONG>-d</STRONG> debugging
  59. switch.  The profiler uses the debugging hooks.  So to profile script
  60. <EM>test.pl</EM> the following command should be used:</P>
  61. <PRE>
  62.         perl5 -d:DProf test.pl</PRE>
  63. <P>When the script terminates (or when the output buffer is filled) the
  64. profiler will dump the profile information to a file called
  65. <EM>tmon.out</EM>.  A tool like <EM>dprofpp</EM> can be used to interpret the
  66. information which is in that profile.  The following command will
  67. print the top 15 subroutines which used the most time:</P>
  68. <PRE>
  69.         dprofpp</PRE>
  70. <P>To print an execution graph of the subroutines in the script use the
  71. following command:</P>
  72. <PRE>
  73.         dprofpp -T</PRE>
  74. <P>Consult <EM>dprofpp</EM> for other options.</P>
  75. <P>
  76. <HR>
  77. <H1><A NAME="profile format">PROFILE FORMAT</A></H1>
  78. <P>The old profile is a text file which looks like this:</P>
  79. <PRE>
  80.         #fOrTyTwO
  81.         $hz=100;
  82.         $XS_VERSION='DProf 19970606';
  83.         # All values are given in HZ
  84.         $rrun_utime=2; $rrun_stime=0; $rrun_rtime=7
  85.         PART2
  86.         + 26 28 566822884 DynaLoader::import
  87.         - 26 28 566822884 DynaLoader::import
  88.         + 27 28 566822885 main::bar
  89.         - 27 28 566822886 main::bar
  90.         + 27 28 566822886 main::baz
  91.         + 27 28 566822887 main::bar
  92.         - 27 28 566822888 main::bar
  93.         [....]</PRE>
  94. <P>The first line is the magic number.  The second line is the hertz value, or
  95. clock ticks, of the machine where the profile was collected.  The third line
  96. is the name and version identifier of the tool which created the profile.
  97. The fourth line is a comment.  The fifth line contains three variables
  98. holding the user time, system time, and realtime of the process while it was
  99. being profiled.  The sixth line indicates the beginning of the sub
  100. entry/exit profile section.</P>
  101. <P>The columns in <STRONG>PART2</STRONG> are:</P>
  102. <PRE>
  103.         sub entry(+)/exit(-) mark
  104.         app's user time at sub entry/exit mark, in ticks
  105.         app's system time at sub entry/exit mark, in ticks
  106.         app's realtime at sub entry/exit mark, in ticks
  107.         fully-qualified sub name, when possible</PRE>
  108. <P>With newer perls another format is used, which may look like this:</P>
  109. <PRE>
  110.         #fOrTyTwO
  111.         $hz=10000;
  112.         $XS_VERSION='DProf 19971213';
  113.         # All values are given in HZ
  114.         $over_utime=5917; $over_stime=0; $over_rtime=5917;
  115.         $over_tests=10000;
  116.         $rrun_utime=1284; $rrun_stime=0; $rrun_rtime=1284;
  117.         $total_marks=6;</PRE>
  118. <PRE>
  119.         PART2
  120.         @ 406 0 406
  121.         & 2 main bar
  122.         + 2
  123.         @ 456 0 456
  124.         - 2
  125.         @ 1 0 1
  126.         & 3 main baz
  127.         + 3
  128.         @ 141 0 141
  129.         + 2
  130.         @ 141 0 141
  131.         - 2
  132.         @ 1 0 1
  133.         & 4 main foo
  134.         + 4
  135.         @ 142 0 142
  136.         + & Devel::DProf::write
  137.         @ 5 0 5
  138.         - & Devel::DProf::write</PRE>
  139. <P>(with high value of $ENV{PERL_DPROF_TICKS}).</P>
  140. <P>New <CODE>$over_*</CODE> values show the measured overhead of making $over_tests
  141. calls to the profiler These values are used by the profiler to
  142. subtract the overhead from the runtimes.</P>
  143. <P>The lines starting with <CODE>@</CODE> mark time passed from the previous <CODE>@</CODE>
  144. line.  The lines starting with <CODE>&</CODE> introduce new subroutine <EM>id</EM> and
  145. show the package and the subroutine name of this id.  Lines starting
  146. with <CODE>+</CODE>, <CODE>-</CODE> and <CODE>*</CODE> mark entering and exit of subroutines by
  147. <EM>id</EM>s, and <CODE>goto &subr</CODE>.</P>
  148. <P>The <EM>old-style</EM> <CODE>+</CODE>- and <CODE>-</CODE>-lines are used to mark the overhead
  149. related to writing to profiler-output file.</P>
  150. <P>
  151. <HR>
  152. <H1><A NAME="autoload">AUTOLOAD</A></H1>
  153. <P>When Devel::DProf finds a call to an <CODE>&AUTOLOAD</CODE> subroutine it looks at the
  154. <CODE>$AUTOLOAD</CODE> variable to find the real name of the sub being called.  See
  155. <A HREF="../../lib/Pod/perlsub.html#autoloading">Autoloading in the perlsub manpage</A>.</P>
  156. <P>
  157. <HR>
  158. <H1><A NAME="environment">ENVIRONMENT</A></H1>
  159. <P><CODE>PERL_DPROF_BUFFER</CODE> sets size of output buffer in words.  Defaults to 2**14.</P>
  160. <P><CODE>PERL_DPROF_TICKS</CODE> sets number of ticks per second on some systems where
  161. a replacement for <A HREF="../../lib/Pod/perlfunc.html#item_times"><CODE>times()</CODE></A> is used.  Defaults to the value of <CODE>HZ</CODE> macro.</P>
  162. <P><CODE>PERL_DPROF_OUT_FILE_NAME</CODE> sets the name of the output file.  If not set,
  163. defaults to tmon.out.</P>
  164. <P>
  165. <HR>
  166. <H1><A NAME="bugs">BUGS</A></H1>
  167. <P>Builtin functions cannot be measured by Devel::DProf.</P>
  168. <P>With a newer Perl DProf relies on the fact that the numeric slot of
  169. $DB::sub contains an address of a subroutine.  Excessive manipulation
  170. of this variable may overwrite this slot, as in</P>
  171. <PRE>
  172.   $DB::sub = 'current_sub';
  173.   ...
  174.   $addr = $DB::sub + 0;</PRE>
  175. <P>will set this numeric slot to numeric value of the string
  176. <CODE>current_sub</CODE>, i.e., to <CODE>0</CODE>.  This will cause a segfault on the exit
  177. from this subroutine.  Note that the first assignment above does not
  178. change the numeric slot (it will <EM>mark</EM> it as invalid, but will not
  179. write over it).</P>
  180. <P>Mail bug reports and feature requests to the perl5-porters mailing list at
  181. <EM><<A HREF="mailto:perl5-porters@perl.org">perl5-porters@perl.org</A>></EM>.</P>
  182. <P>
  183. <HR>
  184. <H1><A NAME="see also">SEE ALSO</A></H1>
  185. <P><A HREF="../../lib/Pod/perl.html">the perl manpage</A>, <EM>dprofpp</EM>, <A HREF="../../lib/Pod/perlfunc.html#item_times"><CODE>times(2)</CODE></A></P>
  186. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  187. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  188. <STRONG><P CLASS=block> Devel::DProf - a Perl code profiler</P></STRONG>
  189. </TD></TR>
  190. </TABLE>
  191.  
  192. </BODY>
  193.  
  194. </HTML>
  195.