1 # Devel::DProf - a Perl code profiler
5 # changes/bugs fixed since 01mar95 version:
6 # - record $pwd and build pathname for tmon.out
7 # (so the profile doesn't get lost if the process chdir's)
8 # changes/bugs fixed since 03feb95 version:
9 # - fixed some doc bugs
10 # - added require 5.000
11 # - added -w note to bugs section of pod
12 # changes/bugs fixed since 31dec94 version:
20 Devel::DProf - a Perl code profiler
24 PERL5DB="use Devel::DProf;"
31 The Devel::DProf package is a Perl code profiler. This will collect
32 information on the execution time of a Perl script and of the subs in that
33 script. This information can be used to determine which subroutines are
34 using the most time and which subroutines are being called most often. This
35 information can also be used to create an execution graph of the script,
36 showing subroutine relationships.
38 To use this package the PERL5DB environment variable must be set to the
41 PERL5DB="use Devel::DProf;"
44 To profile a Perl script run the perl interpreter with the B<-d> debugging
45 switch. The profiler uses the debugging hooks. So to profile script
46 "test.pl" the following command should be used:
50 When the script terminates the profiler will dump the profile information
51 to a file called I<tmon.out>. The supplied I<dprofpp> tool can be used to
52 interpret the information which is in that profile. The following command
53 will print the top 15 subroutines which used the most time:
57 To print an execution graph of the subroutines in the script use the
62 Consult the "dprofpp" manpage for other options.
66 If perl5 is invoked with the B<-w> (warnings) flag then Devel::DProf will
67 cause a large quantity of warnings to be printed.
71 L<perl>, L<dprofpp>, times(2)
77 # So Devel::DProf knows where to drop tmon.out.
79 $tmon = "$pwd/tmon.out";
81 # This sub is replaced by an XS version after the profiler is bootstrapped.
83 # print "nonXS DBsub($sub)\n";
84 $single = 0; # disable DB single-stepping
95 # This sub is needed during startup.
97 # print "nonXS DBDB\n";
102 @Devel::DProf::ISA = qw(DynaLoader);
104 bootstrap Devel::DProf;