Author: tim.bunce
Date: Tue Jul 7 06:24:31 2009
New Revision: 809
Modified:
trunk/demo/demo-code.pl
trunk/demo/demo-run.pl
trunk/lib/Devel/NYTProf/Util.pm
Log:
Added (undocumented) NYTPROF_FMT_TIME env var for experimentation.
Tweaked the demo code
Modified: trunk/demo/demo-code.pl
==============================================================================
--- trunk/demo/demo-code.pl (original)
+++ trunk/demo/demo-code.pl Tue Jul 7 06:24:31 2009
@@ -3,7 +3,7 @@
use File::Find;
my $count = shift || 100;
-my $do_io = shift || 0;
+my $do_io = shift || (not -t STDIN);
sub add {
$a = $a + 1;
Modified: trunk/demo/demo-run.pl
==============================================================================
--- trunk/demo/demo-run.pl (original)
+++ trunk/demo/demo-run.pl Tue Jul 7 06:24:31 2009
@@ -26,10 +26,11 @@
$ENV{NYTPROF} = $NYTPROF . $runs{$run}{NYTPROF} || '';
$ENV{NYTPROF_HTML} = $runs{$run}{NYTPROF_HTML} || '';
- my $cmd = "perl -d:NYTProf demo/demo-code.pl 100 1";
+ my $cmd = "perl -d:NYTProf demo/demo-code.pl @ARGV";
open my $fh, "| $cmd"
or die "Error starting $cmd\n";
+ # feed data into the stdin read loop in demo/demo-code.pl
$fh->autoflush;
print $fh "$_\n" for (1..10);
sleep 2;
@@ -42,7 +43,7 @@
system("perl -Mblib bin/nytprofhtml --open --out=$outdir") == 0
or exit 0;
- system "ls -lrt $outdir/.";
+ #system "ls -lrt $outdir/.";
sleep 1;
}
Modified: trunk/lib/Devel/NYTProf/Util.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Util.pm (original)
+++ trunk/lib/Devel/NYTProf/Util.pm Tue Jul 7 06:24:31 2009
@@ -162,11 +162,15 @@
}
+# XXX undocumented hack that may become to an option one day
+my $fmt_time_opt = $ENV{NYTPROF_FMT_TIME}; # e.g., '%fs'
+
sub fmt_time {
my ($sec, $width) = @_;
$width = '' unless defined $width;
return sprintf "%$width.0fs", 0 unless $sec;
return '-'.fmt_time(-$sec, $width) if $sec < 0; # negative value, can
happen
+ return sprintf $fmt_time_opt, $sec if $fmt_time_opt;
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;
--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---