home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Devel / DProf.pm next >
Encoding:
Perl POD Document  |  1997-08-10  |  3.2 KB  |  118 lines

  1. require 5.003;
  2.  
  3. =head1 NAME
  4.  
  5. Devel::DProf - a Perl code profiler
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.     perl5 -d:DProf test.pl
  10.  
  11. =head1 DESCRIPTION
  12.  
  13. The Devel::DProf package is a Perl code profiler.  This will collect
  14. information on the execution time of a Perl script and of the subs in that
  15. script.  This information can be used to determine which subroutines are
  16. using the most time and which subroutines are being called most often.  This
  17. information can also be used to create an execution graph of the script,
  18. showing subroutine relationships.
  19.  
  20. To profile a Perl script run the perl interpreter with the B<-d> debugging
  21. switch.  The profiler uses the debugging hooks.  So to profile script
  22. F<test.pl> the following command should be used:
  23.  
  24.     perl5 -d:DProf test.pl
  25.  
  26. When the script terminates the profiler will dump the profile information to
  27. a file called F<tmon.out>.  A tool like I<dprofpp> can be used to interpret
  28. the information which is in that profile.  The following command will print
  29. the top 15 subroutines which used the most time:
  30.  
  31.     dprofpp
  32.  
  33. To print an execution graph of the subroutines in the script use the
  34. following command:
  35.  
  36.     dprofpp -T
  37.  
  38. Consult L<dprofpp> for other options.
  39.  
  40. =head1 PROFILE FORMAT
  41.  
  42. The profile is a text file which looks like this:
  43.  
  44.     #fOrTyTwO
  45.     $hz=100;
  46.     $XS_VERSION='DProf 19970606';
  47.     # All values are given in HZ
  48.     $rrun_utime=2; $rrun_stime=0; $rrun_rtime=7
  49.     PART2
  50.     + 26 28 566822884 DynaLoader::import
  51.     - 26 28 566822884 DynaLoader::import
  52.     + 27 28 566822885 main::bar
  53.     - 27 28 566822886 main::bar
  54.     + 27 28 566822886 main::baz
  55.     + 27 28 566822887 main::bar
  56.     - 27 28 566822888 main::bar
  57.     [....]
  58.  
  59. The first line is the magic number.  The second line is the hertz value, or
  60. clock ticks, of the machine where the profile was collected.  The third line
  61. is the name and version identifier of the tool which created the profile.
  62. The fourth line is a comment.  The fifth line contains three variables
  63. holding the user time, system time, and realtime of the process while it was
  64. being profiled.  The sixth line indicates the beginning of the sub
  65. entry/exit profile section.
  66.  
  67. The columns in B<PART2> are:
  68.  
  69.     sub entry(+)/exit(-) mark
  70.     app's user time at sub entry/exit mark, in ticks
  71.     app's system time at sub entry/exit mark, in ticks
  72.     app's realtime at sub entry/exit mark, in ticks
  73.     fully-qualified sub name, when possible
  74.  
  75. =head1 AUTOLOAD
  76.  
  77. When Devel::DProf finds a call to an C<&AUTOLOAD> subroutine it looks at the
  78. C<$AUTOLOAD> variable to find the real name of the sub being called.  See
  79. L<perlsub/"Autoloading">.
  80.  
  81. =head1 BUGS
  82.  
  83. XSUBs, builtin functions, and destructors cannot be measured by Devel::DProf.
  84.  
  85. Mail bug reports and feature requests to the perl5-porters mailing list at
  86. F<E<lt>perl5-porters@africa.nicoh.comE<gt>>.
  87.  
  88. =head1 SEE ALSO
  89.  
  90. L<perl>, L<dprofpp>, times(2)
  91.  
  92. =cut
  93.  
  94. package DB;
  95.  
  96. #
  97. # As of perl5.003_20, &DB::sub stub is not needed (some versions
  98. # even had problems if stub was redefined with XS version).
  99. #
  100.  
  101. # disable DB single-stepping
  102. BEGIN { $single = 0; }
  103.  
  104. # This sub is needed during startup.
  105. sub DB { 
  106. #    print "nonXS DBDB\n";
  107. }
  108.  
  109.  
  110. require DynaLoader;
  111. @Devel::DProf::ISA = 'DynaLoader';
  112. $Devel::DProf::VERSION = '19970614'; # this version not authorized by
  113.                      # Dean Roehrich. See "Changes" file.
  114.  
  115. bootstrap Devel::DProf $Devel::DProf::VERSION;
  116.  
  117. 1;
  118.