Author: tim.bunce
Date: Sun Nov 23 05:03:25 2008
New Revision: 619

Modified:
    trunk/HACKING
    trunk/bin/nytprofhtml
    trunk/lib/Devel/NYTProf/Util.pm

Log:
Add package-level summary idea to HACKING.
Format negative times nicely.
Add thead, tbody and tfoot tags.
Don't show discrepency in times due to string evals if it's very small (ie  
mostly due to float precision).


Modified: trunk/HACKING
==============================================================================
--- trunk/HACKING       (original)
+++ trunk/HACKING       Sun Nov 23 05:03:25 2008
@@ -318,6 +318,8 @@

  Add per-package summary table like the per-sub stats to make it easier to  
see
  a package where a lot of time is being spent in lots of different subs.
+Also a per-top-level-package-name summary, so "Moose::*" would summarize
+all the Moose modules. Probably work best with two-level names.

  Add option to set processor affinity.


Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml       (original)
+++ trunk/bin/nytprofhtml       Sun Nov 23 05:03:25 2008
@@ -173,8 +173,10 @@
      my $sub_links;

      my $sortby_desc = ($sortby eq 'excl_time') ? "exclusive  
time" : "inclusive time";
-    $sub_links .= qq{<table border="1" cellpadding="0">
+    $sub_links .= qq{
+        <table id="subroutines" border="1" cellpadding="0">
          <caption>${qualifier}Subroutines &mdash; ordered by  
$sortby_desc</caption>
+        <thead>
          <tr>
          <th>Calls</th>
          <th><span title="Number of Places sub is called from">P</span></th>
@@ -183,12 +185,14 @@
          <th>Inclusive<br />Time</th>
          <th colspan="2" class="left_indent_header">Subroutine</th>
          </tr>
+        </thead>
      };

      # XXX may not be appropriate if profiling wasn't continuous
      my $profiler_duration = $profile->{attribute}{profiler_duration};

      my @rows;
+    $sub_links .= "<tbody>\n";
      for my $sub (@subs_to_show) {

          # in the overall summary, don't list subs that were never called
@@ -232,6 +236,7 @@

          $sub_links .= "</tr>\n";
      }
+    $sub_links .= "</tbody>\n";
      $sub_links .= "</table>\n";

      return $sub_links;
@@ -246,8 +251,11 @@

          return qq{$sub_links
        <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>\n
+      </thead>
+      <tbody>
      };
      }
  );
@@ -257,7 +265,7 @@
      sub {
          my ($profile, $filestr) = @_;
          my $footer = get_footer($profile);
-        return "</table></div>$footer</body></html>";
+        return "</tbody></table></div>$footer</body></html>";
      }
  );

@@ -597,8 +605,13 @@
          <table border="1" cellspacing="0">
          <caption>Source Code Files &mdash; ordered by exclusive time then  
name</caption>
      };
-    print OUT qq{<tr class="index"><th>Stmts</th><th>Exclusive<br  
/>Time</th>}
-        . "<th>Avg.</th><th>Reports</th><th>Source File</th></tr>";
+    print OUT qq{
+        <thead><tr class="index">
+        <th>Stmts</th><th>Exclusive<br />Time</th>
+        <th>Avg.</th><th>Reports</th><th>Source File</th>
+        </tr></thead>
+        <tbody>
+    };

      my $inc_path_regex = get_abs_paths_alternation_regex([$profile->inc],  
qr/^|\[/);

@@ -637,14 +650,20 @@
              $fi->fid, $fi->abs_filename, $fi->filename_without_inc;
          print OUT "</tr>\n";
      }
+    print OUT "</tbody>\n";
+
      if ($add_totals) {
+        print OUT "<tfoot>\n";
          my $stats_fmt =
              qq{<tr class="index"><td class="n">%s</td><td  
class="n">%s</td><td class="n">%s</td><td colspan="2" style="font-style:  
italic">%s</td></tr>};
          my $t_notes = "";
-        if ($t_stmt_exec != $allCalls or $t_stmt_time ne $allTimes) {
+        my $stmt_time_diff = $allTimes - $t_stmt_time;
+        if ($t_stmt_exec != $allCalls or $stmt_time_diff > 0.000_010) {
              my $eval_fileinfos = grep { $_->eval_line }  
$profile->all_fileinfos;
-            $t_notes = sprintf "(%d string evals account for a further %d  
statements and %s)</i>",
-                $eval_fileinfos, $allCalls - $t_stmt_exec,  
fmt_time($allTimes - $t_stmt_time);
+            $stmt_time_diff = ($stmt_time_diff > 0.000_010)
+                ? sprintf(" and %s", fmt_time($stmt_time_diff)) : "";
+            $t_notes = sprintf "(%d string evals account for a further %d  
statements%s)</i>",
+                $eval_fileinfos, $allCalls - $t_stmt_exec, $stmt_time_diff;
          }
          print OUT sprintf $stats_fmt, fmt_float($t_stmt_exec),  
fmt_time($t_stmt_time), '',
              "Total $t_notes";
@@ -658,6 +677,7 @@
          print OUT sprintf $stats_fmt, '', fmt_float($dev_time->[0]),  
fmt_float($dev_avgt->[0]),
              "Deviation"
              if $dev_time->[0] or $dev_avgt->[0];
+        print OUT "</tfoot>\n";
      }
      print OUT '</table>';


Modified: trunk/lib/Devel/NYTProf/Util.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Util.pm     (original)
+++ trunk/lib/Devel/NYTProf/Util.pm     Sun Nov 23 05:03:25 2008
@@ -165,7 +165,7 @@
      my ($sec, $width) = @_;
      $width = '' unless defined $width;
      return sprintf "%$width.0f", 0     unless $sec;
-    return sprintf "%gs", $sec         if $sec < 0; # negative value, can  
happen
+    return '-'.fmt_time(-$sec, $width) 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;

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