X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=utils%2Fdprofpp.PL;h=ef994884320efa401394b0f4b980957db8213726;hb=3cf20fa2fb953d611f6cc722b308008b48536e07;hp=8c2ef79da0b8f9206e24b5695cf1f3e8894bd411;hpb=ccc0622a5e7618aee538d32edf64a5e4687cd025;p=p5sagit%2Fp5-mst-13.2.git diff --git a/utils/dprofpp.PL b/utils/dprofpp.PL index 8c2ef79..ef99488 100644 --- a/utils/dprofpp.PL +++ b/utils/dprofpp.PL @@ -14,9 +14,8 @@ use File::Spec; # This forces PL files to create target in same directory as PL file. # This is so that make depend always knows where to find PL derivatives. chdir(dirname($0)); -($file = basename($0)) =~ s/\.PL$//; -$file =~ s/\.pl$// if ($Config{'osname'} eq 'OS2'); # "case-forgiving" -$file =~ s/\.pl$/.com/ if ($Config{'osname'} eq 'VMS'); # "case-forgiving" +($file = basename($0)) =~ s/\.PL$//i; +$file .= '.COM' if ($^O eq 'VMS'); my $dprof_pm = File::Spec->catfile(File::Spec->updir, 'ext', 'Devel', 'DProf', 'DProf.pm'); my $VERSION = 0; @@ -82,13 +81,12 @@ dprofpp B<-V> [profile] The I command interprets profile data produced by a profiler, such as the Devel::DProf profiler. Dprofpp will read the file F and -will display the 15 subroutines which are using the most time. By default +display the 15 subroutines which are using the most time. By default the times for each subroutine are given exclusive of the times of their child subroutines. To profile a Perl script run the perl interpreter with the B<-d> switch. So -to profile script F with Devel::DProf the following command should -be used. +to profile script F with Devel::DProf use the following: $ perl5 -d:DProf test.pl @@ -244,7 +242,7 @@ times in the same branch then all these calls go into one branch of the next level. A repeat count is output together with combined inclusive, exclusive and kids time. -Branches are sorted w.r.t. inclusive time. +Branches are sorted with regard to inclusive time. =item B<-U> @@ -286,12 +284,20 @@ or to group subroutines by name: =item B<-P> -Used with -G to aggregate "Pull" together all calls that did not match -G. +Used with -G to aggregate "Pull" together all calls that did not match -G. =item B<-f> Filter all calls matching the pattern. +=item B<-h> + +Display brief help and exit. + +=item B<-H> + +Display long help and exit. + =back =head1 ENVIRONMENT @@ -327,11 +333,46 @@ L, L, times(2) =cut +sub shortusage { + print <<'EOF'; +dprofpp [options] [profile] + + -A Count autoloaded to *AUTOLOAD. + -a Sort by alphabetic name of subroutines. + -d Reverse sort. + -E Sub times are reported exclusive of child times. (default) + -f Filter all calls matching the pattern. + -G Group all calls matching the pattern together. + -g subr Count only subs who are SUBR or called from SUBR. + -H Display long manual page. + -h Display this short usage message. + -I Sub times are reported inclusive of child times. + -l Sort by number of calls to subroutines. + -O cnt Specifies maximum number of subroutines to display. + -P Used with -G to pull all other calls together. + -p script Specifies name of script to be profiled. + -Q Used with -p to indicate that dprofpp should quit + after profiling the script, without interpreting the data. + -q Do not print column headers. + -R Count anonymous subs separately even if from the same package. + -r Use real elapsed time rather than user+system time. + -S Create statistics for all the depths. + -s Use system time rather than user+system time. + -T Show call tree. + -t Show call tree, compressed. + -U Do not sort subroutines. + -u Use user time rather than user+system time. + -V Print dprofpp's version. + -v Sort by average amount of time spent in subroutines. + -z Sort by user+system time spent in subroutines. (default) +EOF +} + use Getopt::Std 'getopts'; use Config '%Config'; Setup: { - my $options = 'O:g:G:Pf:dlzaAvuTtqrRsUFEIp:QVS'; + my $options = 'O:g:G:Pf:dlzaAvuTtqrRsUFEIp:QVShH'; $Monfile = 'tmon.out'; if( exists $ENV{DPROFPP_OPTS} ){ @@ -345,39 +386,21 @@ Setup: { @ARGV = @tmpargv; } - getopts( $options ); + getopts( $options ) or die "Try 'dprofpp -h' for help.\n"; if( @ARGV ){ # there was a filename, it overrides any earlier name. $Monfile = shift; } -# -O cnt Specifies maximum number of subroutines to display. -# -a Sort by alphabetic name of subroutines. -# -z Sort by user+system time spent in subroutines. (default) -# -l Sort by number of calls to subroutines. -# -v Sort by average amount of time spent in subroutines. -# -T Show call tree. -# -t Show call tree, compressed. -# -q Do not print column headers. -# -u Use user time rather than user+system time. -# -s Use system time rather than user+system time. -# -r Use real elapsed time rather than user+system time. -# -U Do not sort subroutines. -# -E Sub times are reported exclusive of child times. (default) -# -I Sub times are reported inclusive of child times. -# -V Print dprofpp's version. -# -p script Specifies name of script to be profiled. -# -Q Used with -p to indicate the dprofpp should quit after -# profiling the script, without interpreting the data. -# -A count autoloaded to *AUTOLOAD -# -R count anonyms separately even if from the same package -# -g subr count only those who are SUBR or called from SUBR -# -S Create statistics for all the depths - -# -G Group all calls matching the pattern together. -# -P Used with -G to pull all other calls together. -# -f Filter all calls mathcing the pattern. -# -d Reverse sort + if ( defined $opt_h ) { + shortusage(); + exit; + } + if ( defined $opt_H ) { + require Pod::Usage; + Pod::Usage::pod2usage( {-verbose => 2, -input => $0 } ); + exit; + } if( defined $opt_V ){ my $fh = 'main::fh'; @@ -712,7 +735,7 @@ sub parsestack { my $ot = $t; if ( $dir eq '/' ) { - $syst = $stack[-1][0]; + $syst = $stack[-1][0] if scalar @stack; $usert = '&'; $dir = '-'; #warn("Inserted exit for $stack[-1][0].\n") @@ -740,9 +763,9 @@ sub parsestack { } add_to_tree($curdeep_times, $ename, $t - $overhead) if $opt_S; - exitstamp( \@stack, \@tstack, - $t - $overhead, - $times, $ctimes, $ename, \$in, $tab, + exitstamp( \@stack, \@tstack, + $t - $overhead, + $times, $ctimes, $name, \$in, $tab, $curdeep_times, \%outer ); } next unless $in_level or $name eq $opt_g;