1N/A# List explicitly here the variables you want Configure to 1N/A# generate. Metaconfig only looks for shell variables, so you 1N/A# have to mention them as if they were shell variables, not 1N/A# %Config entries. Thus you write 1N/A# to ensure Configure will look for $Config{startperl}. 1N/A# This forces PL files to create target in same directory as PL file. 1N/A# This is so that make depend always knows where to find PL derivatives. 1N/Aopen(
PM,
"<$dprof_pm" ) ||
die "Can't open $dprof_pm: $!";
1N/A die "Did not find VERSION in $dprof_pm";
1N/Aopen OUT,
">$file" or die "Can't create $file: $!";
1N/Aprint "Extracting $file (with variable substitutions)\n";
1N/A# In this section, perl variables will be expanded during extraction. 1N/A# You can use $Config{...} to use Configure variables. 1N/A eval 'exec perl -S \$0 "\$@"' 1N/A# In the following, perl variables are not expanded during extraction. 1N/Adprofpp - display perl profile data 1N/Adprofpp [B<-a>|B<-z>|B<-l>|B<-v>|B<-U>] [B<-d>] [B<-s>|B<-r>|B<-u>] [B<-q>] [B<-F>] [B<-I|-E>] [B<-O cnt>] [B<-A>] [B<-R>] [B<-S>] [B<-g subroutine>] [B<-G> <regexp> [B<-P>]] [B<-f> <regexp>] [profile] 1N/Adprofpp B<-T> [B<-F>] [B<-g subroutine>] [profile] 1N/Adprofpp B<-t> [B<-F>] [B<-g subroutine>] [profile] 1N/Adprofpp B<-G> <regexp> [B<-P>] [profile] 1N/Adprofpp B<-p script> [B<-Q>] [other opts] 1N/Adprofpp B<-V> [profile] 1N/AThe I<dprofpp> command interprets profile data produced by a profiler, such 1N/Aas the Devel::DProf profiler. Dprofpp will read the file F<tmon.out> and 1N/Awill display the 15 subroutines which are using the most time. By default 1N/Athe times for each subroutine are given exclusive of the times of their 1N/ATo profile a Perl script run the perl interpreter with the B<-d> switch. So 1N/Ato profile script F<test.pl> with Devel::DProf the following command should 1N/AThen run dprofpp to analyze the profile. The output of dprofpp depends 1N/Aon the flags to the program and the version of Perl you're using. 1N/A Total Elapsed Time = 1.67 Seconds 1N/A User Time = 0.61 Seconds 1N/A 52.4 0.320 2 0.1600 main::foo 1N/A 45.9 0.280 200 0.0014 main::bar 1N/A 0.00 0.000 1 0.0000 DynaLoader::import 1N/A 0.00 0.000 1 0.0000 main::baz 1N/AThe dprofpp tool can also run the profiler before analyzing the profile 1N/Adata. The above two commands can be executed with one dprofpp command. 1N/AConsult L<Devel::DProf/"PROFILE FORMAT"> for a description of the raw profile. 1N/APercentage of time spent in this routine. 1N/ANumber of calls to this routine. 1N/AAverage number of seconds per call to this routine. 1N/ATime (in seconds) spent in this routine and routines called from it. 1N/ATime (in seconds) spent in this routine (not including those called 1N/AAverage time (in seconds) spent in each call of this routine 1N/A(including those called from it). 1N/ASort alphabetically by subroutine names. 1N/AReverse whatever sort is used 1N/ACount timing for autoloaded subroutine as timing for C<*::AUTOLOAD>. 1N/AOtherwise the time to autoload it is counted as time of the subroutine 1N/Aitself (there is no way to separate autoload time from run time). 1N/AThis is going to be irrelevant with newer Perls. They will inform 1N/AC<Devel::DProf> I<when> the C<AUTOLOAD> switches to actual subroutine, 1N/Aso a separate statistics for C<AUTOLOAD> will be collected no matter 1N/Awhether this option is set. 1N/ACount anonymous subroutines defined in the same package separately. 1N/A(default) Display all subroutine times exclusive of child subroutine times. 1N/AForce the generation of fake exit timestamps if dprofpp reports that the 1N/Aprofile is garbled. This is only useful if dprofpp determines that the 1N/Aprofile is garbled due to missing exit timestamps. You're on your own if 1N/Ayou do this. Consult the BUGS section. 1N/ADisplay all subroutine times inclusive of child subroutine times. 1N/ASort by number of calls to the subroutines. This may help identify 1N/Acandidates for inlining. 1N/AShow only I<cnt> subroutines. The default is 15. 1N/ATells dprofpp that it should profile the given script and then interpret its 1N/Aprofile data. See B<-Q>. 1N/AUsed with B<-p> to tell dprofpp to quit after profiling the script, without 1N/Ainterpreting the data. 1N/ADo not display column headers. 1N/ADisplay elapsed real times rather than user+system times. 1N/ADisplay system times rather than user+system times. 1N/ADisplay subroutine call tree to stdout. Subroutine statistics are 1N/ADisplay subroutine call tree to stdout. Subroutine statistics are not 1N/Adisplayed. When a function is called multiple consecutive times at the same 1N/Acalling level then it is displayed once with a repeat count. 1N/ADisplay I<merged> subroutine call tree to stdout. Statistics are 1N/Adisplayed for each branch of the tree. 1N/AWhen a function is called multiple (I<not necessarily consecutive>) 1N/Atimes in the same branch then all these calls go into one branch of 1N/Athe next level. A repeat count is output together with combined 1N/Ainclusive, exclusive and kids time. 1N/ABranches are sorted w.r.t. inclusive time. 1N/ADo not sort. Display in the order found in the raw profile. 1N/ADisplay user times rather than user+system times. 1N/APrint dprofpp's version number and exit. If a raw profile is found then its 1N/AXS_VERSION variable will be displayed, too. 1N/ASort by average time spent in subroutines during each call. This may help 1N/Aidentify candidates for inlining. 1N/A(default) Sort by amount of user+system time used. The first few lines 1N/Ashould show you which subroutines are using the most time. 1N/A=item B<-g> C<subroutine> 1N/AIgnore subroutines except C<subroutine> and whatever is called from it. 1N/AAggregate "Group" all calls matching the pattern together. 1N/AFor example this can be used to group all calls of a set of packages 1N/A -G "(package1::)|(package2::)|(package3::)" 1N/Aor to group subroutines by name: 1N/AUsed with -G to aggregate "Pull" together all calls that did not match -G. 1N/AFilter all calls matching the pattern. 1N/AThe environment variable B<DPROFPP_OPTS> can be set to a string containing 1N/Aoptions for dprofpp. You might use this if you prefer B<-I> over B<-E> or 1N/Aif you want B<-F> on all the time. 1N/AThis was added fairly lazily, so there are some undesirable side effects. 1N/AOptions on the commandline should override options in DPROFPP_OPTS--but 1N/Adon't count on that in this version. 1N/AApplications which call _exit() or exec() from within a subroutine 1N/Awill leave an incomplete profile. See the B<-F> option. 1N/AAny bugs in Devel::DProf, or any profiler generating the profile data, could 1N/AMail bug reports and feature requests to the perl5-porters mailing list at 1N/AF<E<lt>perl5-porters@perl.orgE<gt>>. Bug reports should include the 1N/Aoutput of the B<-V> option. 1N/A dprofpp - profile processor 1N/A tmon.out - raw profile 1N/AL<perl>, L<Devel::DProf>, times(2) 1N/A # there was a filename. 1N/A # there was a filename, it overrides any earlier name. 1N/A# -O cnt Specifies maximum number of subroutines to display. 1N/A# -a Sort by alphabetic name of subroutines. 1N/A# -z Sort by user+system time spent in subroutines. (default) 1N/A# -l Sort by number of calls to subroutines. 1N/A# -v Sort by average amount of time spent in subroutines. 1N/A# -t Show call tree, compressed. 1N/A# -q Do not print column headers. 1N/A# -u Use user time rather than user+system time. 1N/A# -s Use system time rather than user+system time. 1N/A# -r Use real elapsed time rather than user+system time. 1N/A# -U Do not sort subroutines. 1N/A# -E Sub times are reported exclusive of child times. (default) 1N/A# -I Sub times are reported inclusive of child times. 1N/A# -V Print dprofpp's version. 1N/A# -p script Specifies name of script to be profiled. 1N/A# -Q Used with -p to indicate the dprofpp should quit after 1N/A# profiling the script, without interpreting the data. 1N/A# -A count autoloaded to *AUTOLOAD 1N/A# -R count anonyms separately even if from the same package 1N/A# -g subr count only those who are SUBR or called from SUBR 1N/A# -S Create statistics for all the depths 1N/A# -G Group all calls matching the pattern together. 1N/A# -P Used with -G to pull all other calls together. 1N/A# -f Filter all calls mathcing the pattern. 1N/A print "$0 version: $VERSION\n";
1N/A open( $
fh,
"<$Monfile" ) &&
do {
1N/A print "XS_VERSION: $XS_VERSION\n";
1N/A $
Monfile =
'tmon.out';
# because that's where it is 1N/A die "-Q is meaningful only when used with -p\n";
1N/A open( $
fh,
"<$monout" ) ||
die "Unable to open $monout\n";
1N/A print "Option G Grouping: [$opt_G]\n";
1N/A # create entries to store grouping 1N/A # Sum calls for the grouping 1N/A print "Grouping [$opt_G] Calls: [$$calls{$opt_G}]\n".
1N/A "Grouping [$opt_G] Times: [$$times{$opt_G}]\n".
1N/A "Grouping [$opt_G] IncTimes: [$$ctimes{$opt_G}]\n";
1N/A# Sets $runtime to user, system, real, or user+system time. The 1N/A# result is given in seconds. 1N/A # When summing, take into account non-rounded-up kids time. 1N/A $
time =
sprintf '%.*fs = (%.*f + %.*f)',
1N/A print ' ' x (
2*$
level),
"$name x $deep_times->{count} \t${time}s\n" 1N/A# Report the times in seconds. 1N/A #format: $ncalls, $name, $secs, $percall, $pcnt 1N/A # Now transfer to the new node (could not do earlier, since name can change) 1N/A # remember last call depth and function name 1N/A #warn("Inserted exit for $stack[-1][0].\n") 1N/A if (
defined $
realt) {
# '+ times nam' '- times nam' or '@ incr' 1N/A $t += $
ot,
next if $
dir eq '@';
# Increments there 1N/A # "- id" or "- & name" 1N/A if ($
name eq "Devel::DProf::write") {
1N/A if ($
name eq "Devel::DProf::write") {
1N/A print ' ' x $
in,
"$name\n";
1N/A # suppress output on same function if the 1N/A # same calling level is called. 1N/A print ' ' x $
l_in,
"$l_name$repstr\n" 1N/A # my children will put their time here 1N/A die "Bad profile: $_";
1N/A print ' ' x $
l_in,
"$l_name$repstr\n";
1N/A warn "$key has $count unstacked calls in outer\n";
1N/A warn "Garbled profile is missing some exit time stamps:\n";
1N/A die "Try rerunning dprofpp with -F.\n";
1N/A # I don't want -F to be default behavior--yet 1N/A warn(
"Faking " .
scalar( @
stack ) .
" exit timestamp(s).\n");
1N/A die "Garbled profile, missing an enter time stamp";
1N/A warn(
"Garbled profile, faking exit timestamp:\n\t$name => $x->[0].\n");
1N/A die "Garbled profile, unexpected exit time stamp";
1N/A # total time this func has been active 1N/A # pass my time to my parent 1N/A if( ! /^
#fOrTyTwO$/ ){ 1N/A die "Not a perl profile";
1N/A# Report avg time-per-function in seconds 1N/A# Runs the given script with the given profiler and the given perl. 1N/A die "Failed: $startperl -d:$profiler $cmd: $!";
1N/A my $
fmt =
' ^>>> ^>>>> ^>>>>> ^>>>>> ^>>>>> ^>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<';
1N/A eval "format STAT = \n$fmt" .
' 1N/Aclose OUT or die "Can't close $file: $!";
1N/Achmod 0755, $
file or die "Can't reset permissions for $file: $!\n";
1N/Aexec(
"$Config{'eunicefix'} $file")
if $
Config{
'eunicefix'}
ne ':';