Author: tim.bunce
Date: Wed Oct 29 16:33:56 2008
New Revision: 578
Modified:
trunk/Changes
trunk/bin/nytprofhtml
trunk/lib/Devel/NYTProf/Util.pm
Log:
Thank Gisle in the Changes file.
Add optional width arg to fmt_time.
Use that to tidy the "spent %s making %*d call%s to" lines.
(I looked at using fmt_time for the statement timings but chickened out.
Devel::NYTProf::Reader needs refactoring to death.)
Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Wed Oct 29 16:33:56 2008
@@ -43,6 +43,8 @@
Assorted report formating enhancements thanks to Gisle Aas.
+ Added Devel::NYTProf::ReadStream module thanks to Gisle Aas.
+
Exclusive and Inclusive time column positions have been switched
to be consistent with how the times are presented elsewhere.
Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml (original)
+++ trunk/bin/nytprofhtml Wed Oct 29 16:33:56 2008
@@ -253,6 +253,11 @@
}
);
+
+$reporter->set_param('column1', {value => 'calls', func =>
\&determine_severity});
+$reporter->set_param('column2', {value => 'time', func =>
\&determine_severity});
+$reporter->set_param('column3', {value => 'time/call', func =>
\&determine_severity});
+
$reporter->set_param(
'column4',
{ func => sub {
@@ -337,7 +342,7 @@
$epilogue = join "\n", map {
my ($count, $incl_time, $reci_time, $rec_depth) =
(@{$calls->{$_}})[0,1,5,6];
my $html = sprintf qq{%s# spent %s making %*d call%s
to }, $ws,
- fmt_time($incl_time+$reci_time),
length($max_calls_to),
+ fmt_time($incl_time+$reci_time, 5),
length($max_calls_to),
$count, $count == 1 ? "" : "s";
$html .= sprintf qq{<a %s>%s</a>},
$reporter->href_for_sub($_), $_;
$html .= sprintf qq{, avg %s/call},
fmt_time($incl_time / $count)
@@ -353,11 +358,6 @@
},
}
);
-
-
-$reporter->set_param('column1', {value => 'calls', func =>
\&determine_severity});
-$reporter->set_param('column2', {value => 'time', func =>
\&determine_severity});
-$reporter->set_param('column3', {value => 'time/call', func =>
\&determine_severity});
$reporter->set_param('lineend', { func => sub { "</tr>\n" } });
Modified: trunk/lib/Devel/NYTProf/Util.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Util.pm (original)
+++ trunk/lib/Devel/NYTProf/Util.pm Wed Oct 29 16:33:56 2008
@@ -148,13 +148,14 @@
}
sub fmt_time {
- my $sec = shift;
- return 0 unless $sec;
- return sprintf "%.0fns", $sec * 1e9 if
$sec < 1e-6;
- return sprintf "%.0fµs", $sec * 1e6 if
$sec < 1e-3;
- return sprintf "%.*fms", 3 - length(int($sec * 1e3)), $sec * 1e3 if
$sec < 1;
- return sprintf "%.*fs", 3 - length(int($sec)), $sec if
$sec < 100;
- return sprintf "%.0fs", $sec;
+ my ($sec, $width) = @_;
+ $width = '' unless defined $width;
+ return sprintf "%$width.0f", 0 unless $sec;
+ return sprintf "%$width.0fns", $sec * 1e9
if $sec < 1e-6;
+ return sprintf "%$width.0fµs", $sec * 1e6
if $sec < 1e-3;
+ return sprintf "%$width.*fms", 3 - length(int($sec * 1e3)), $sec * 1e3
if $sec < 1;
+ return sprintf "%$width.*fs", 3 - length(int($sec)), $sec
if $sec < 100;
+ return sprintf "%$width.0fs", $sec;
}
sub fmt_incl_excl_time {
--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---