Author: tim.bunce
Date: Thu Jul 2 13:12:46 2009
New Revision: 793
Modified:
trunk/Changes
trunk/bin/nytprofhtml
trunk/demo/demo-code.pl
trunk/lib/Devel/NYTProf/Reader.pm
Log:
Added columns to the main source code reports to show
a count of sub calls and time spent in those calls.
Assorted cosmetic improvements.
Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Thu Jul 2 13:12:46 2009
@@ -17,6 +17,11 @@
in the current package with names prefixed by "CORE:".
XXX needs docs and more ops
+ Added columns to the main source code reports to show
+ a count of sub calls and time spent in those calls.
+
+ Assorted cosmetic improvements.
+
=head2 Changes in Devel::NYTProf 2.10 (svn r774) 18th June 2009
Fixed call count for XSubs that was one too high.
Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml (original)
+++ trunk/bin/nytprofhtml Thu Jul 2 13:12:46 2009
@@ -402,7 +402,14 @@
$treemap
<table border="1" cellpadding="0">
<thead>
- <tr><th>Line</th><th>Stmts.</th><th>Exclusive<br
/>Time</th><th>Avg.</th><th class="left_indent_header">Code</th>
+ <tr><th>Line</th>
+ <th><span title="Number of statements executed">State<br
/>-ments</span></th>
+ <th><span title="Time spend executing statements on the line,
+ excluding time spent executing statements in any called
subroutines">Time<br />on line</span></th>
+ <th><span title="Average exclusive time per statement
execution">Avg.<br />Time</span></th>
+ <th><span title="Number of subroutines calls">Calls</span></th>
+ <th><span title="Time spent in subroutines called">Time<br />in
subs</span></th>
+ <th class="left_indent_header">Code</th>
</tr>\n
</thead>
<tbody>
@@ -425,7 +432,7 @@
my $l = sprintf(qq{<td class="h"><a name="%s"></a>%s</td>}, $linenum,
$linenum);
my $s = report_src_line(undef, $linenum, $line, $profile,
$subs_defined, $makes_calls_to, $filestr);
- return "<tr>$l<td></td><td></td><td></td>$s</tr>\n"
+ return "<tr>$l<td></td><td></td><td></td><td></td><td></td>$s</tr>\n"
if not %$stats_for_line;
return join "",
@@ -433,6 +440,8 @@
determine_severity($stats_for_line->{'calls'},
$stats_for_file->{'calls'}),
determine_severity($stats_for_line->{'time'},
$stats_for_file->{'time'}, 1),
determine_severity($stats_for_line->{'time/call'},
$stats_for_file->{'time/call'}, 1),
+ determine_severity($stats_for_line->{'subcall_count'},
$stats_for_file->{subcall_count}, 0),
+ determine_severity($stats_for_line->{'subcall_time'},
$stats_for_file->{subcall_time}, 1),
$s, "</tr>\n";
}
@@ -1654,6 +1663,7 @@
background-color: #dddddd;
border: solid 1px #666666;
padding: 0em 0.4em 0em 0.4em;
+ font-size:0.8em;
}
td {
border: solid 1px #cccccc;
Modified: trunk/demo/demo-code.pl
==============================================================================
--- trunk/demo/demo-code.pl (original)
+++ trunk/demo/demo-code.pl Thu Jul 2 13:12:46 2009
@@ -46,7 +46,7 @@
return $n if $n < 2;
fib($n-1) + fib($n-2);
}
-fib(7);
+fib(42);
# --- File::Find ---
Modified: trunk/lib/Devel/NYTProf/Reader.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Reader.pm (original)
+++ trunk/lib/Devel/NYTProf/Reader.pm Thu Jul 2 13:12:46 2009
@@ -18,6 +18,8 @@
use Carp;
use Config;
+use List::Util qw(sum);
+
use Devel::NYTProf::Data;
use Devel::NYTProf::Util qw(
strip_prefix_from_paths
@@ -102,11 +104,6 @@
callsfunc => undef,
timefunc => undef,
'time/callsfunc' => undef,
- numeric_precision => {
- time => 7,
- calls => 0,
- 'time/call' => 7
- },
};
bless($self, $class);
@@ -288,10 +285,14 @@
# (should equal sum of $stats_accum)
my $runningTotalCalls = 0; # holds the running total number of
calls.
+ # { linenumber => { subname => [ count, time ] } }
+ my $subcalls_at_line = $profile->line_calls_for_file($filestr, 1);
+
# note that a file may have no source lines executed, so no keys
here
# (but is included because some xsubs in the package were executed)
- foreach my $key (keys %{$data->{$filestr}}) {
- my $a = $data->{$filestr}->{$key};
+ foreach my $linenum (keys %{$data->{$filestr}}) {
+ my $a = $data->{$filestr}->{$linenum};
+ my $line_stats = $stats_by_line{$linenum} ||= {};
if (0 == $a->[1]) {
@@ -316,10 +317,20 @@
push(@{$stats_accum{'calls'}}, $a->[1]);
push(@{$stats_accum{'time/call'}}, $time / $a->[1]);
- $stats_by_line{$key}->{'time'} += $time;
- $stats_by_line{$key}->{'calls'} += $a->[1];
- $stats_by_line{$key}->{'time/call'} =
- $stats_by_line{$key}->{'time'} /
$stats_by_line{$key}->{'calls'};
+ $line_stats->{'time'} += $time;
+ $line_stats->{'calls'} += $a->[1];
+ $line_stats->{'time/call'} =
+ $line_stats->{'time'} / $line_stats->{'calls'};
+
+ if (my $subcalls = $subcalls_at_line->{$linenum}) {
+ my $subcall_count = sum(map { $_->[0] } values %$subcalls);
+ my $subcall_time = sum(map { $_->[1] } values %$subcalls);
+ $line_stats->{'subcall_count'} = $subcall_count;
+ $line_stats->{'subcall_time'} = $subcall_time;
+ $line_stats->{'subcall_info'} = $subcalls;
+ push @{$stats_accum{'subcall_count'}}, $subcall_count;
+ push @{$stats_accum{'subcall_time'}}, $subcall_time;
+ }
$runningTotalTime += $time;
$runningTotalCalls += $a->[1];
@@ -336,9 +347,10 @@
'calls' =>
calculate_median_absolute_deviation($stats_accum{'calls'}||[]),
'time' =>
calculate_median_absolute_deviation($stats_accum{'time'}||[]),
'time/call' =>
calculate_median_absolute_deviation($stats_accum{'time/call'}||[]),
+ subcall_count =>
calculate_median_absolute_deviation($stats_accum{subcall_count}||[]),
+ subcall_time =>
calculate_median_absolute_deviation($stats_accum{subcall_time}||[]),
);
- my $line_calls_hash = $profile->line_calls_for_file($filestr, 1);
my $subs_defined_hash = $profile->subs_defined_in_file($filestr,
1);
# the output file name that will be open later. Not including
directory at this time.
@@ -412,7 +424,7 @@
unless our $line_directive_warn->{$filestr}++; # once
per file
}
- my $makes_calls_to = $line_calls_hash->{$LINE} || {};
+ my $makes_calls_to = $subcalls_at_line->{$LINE} || {};
my $subs_defined = $subs_defined_hash->{$LINE} || [];
my $stats_for_line = $stats_by_line{$LINE} || {};
--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]
-~----------~----~----~----~------~----~------~--~---