Author: tim.bunce
Date: Wed Nov 12 02:39:39 2008
New Revision: 592

Modified:
    trunk/lib/Devel/NYTProf/Util.pm

Log:
Format negative time values as seconds, not nanoseconds.


Modified: trunk/lib/Devel/NYTProf/Util.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Util.pm     (original)
+++ trunk/lib/Devel/NYTProf/Util.pm     Wed Nov 12 02:39:39 2008
@@ -147,16 +147,19 @@
      return $val;
  }

+
  sub fmt_time {
      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&micro;s", $sec * 1e6                         
if $sec < 1e-3;
+    return sprintf "%$width.0f", 0     unless $sec;
+    return sprintf "%gs", $sec         if $sec < 0; # negative value, can  
happen
+    return sprintf "%$width.0fns",                              $sec * 1e9  
if $sec < 1e-6;
+    return sprintf "%$width.0f&micro;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.*fs",  3 - length(int($sec      )), $sec        
if $sec < 100;
      return sprintf "%$width.0fs", $sec;
  }
+

  sub fmt_incl_excl_time {
      my ($incl, $excl) = @_;

--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---

Reply via email to