Author: tim.bunce
Date: Mon Nov 24 03:05:04 2008
New Revision: 623

Modified:
    trunk/bin/nytprofhtml

Log:
Merge the separate pkg and sub name columns in the sub table
so that, for example, full names can be copied and pasted without
an extra space or tab appearing.
Fix sorting of sub names.


Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml       (original)
+++ trunk/bin/nytprofhtml       Mon Nov 24 03:05:04 2008
@@ -163,6 +163,9 @@
          sort { $b->$sortby <=> $a->$sortby or $a->subname cmp $b->subname }
          values %$subs_in_file;

+    # in the overall summary, don't show subs that were never called
+    @subs = grep { $_->calls > 0 } @subs if !$filestr;
+
      my $dev_incl_time  = calc_mad_from_objects([EMAIL PROTECTED], 
'incl_time',    1);
      my $dev_excl_time  = calc_mad_from_objects([EMAIL PROTECTED], 
'excl_time',    1);
      my $dev_calls      = calc_mad_from_objects([EMAIL PROTECTED], 'calls',    
    1);
@@ -171,6 +174,7 @@

      my @subs_to_show = ($max_subs) ? splice @subs, 0, $max_subs : @subs;
      my $qualifier = (@subs > @subs_to_show) ? "Top $max_subs " : "";
+    my $max_pkg_name_len = max(map { length($_->package) } @subs_to_show);

      my $sub_links;

@@ -185,7 +189,7 @@
          <th><span title="Number of Files sub is called from">F</span></th>
          <th>Exclusive<br />Time</th>
          <th>Inclusive<br />Time</th>
-        <th colspan="2" class="left_indent_header">Subroutine</th>
+        <th>Subroutine</th>
          </tr>
          </thead>
      };
@@ -197,9 +201,6 @@
      $sub_links .= "<tbody>\n";
      for my $sub (@subs_to_show) {

-        # in the overall summary, don't list subs that were never called
-        next if !$filestr and $sub->calls == 0;
-
          $sub_links .= "<tr>";

          $sub_links .= determine_severity($sub->calls        || 0,  
$dev_calls);
@@ -215,25 +216,21 @@
          # package and subname
          my $subname = $sub->subname;
          my ($pkg, $subr) = ($subname =~ /^(.*::)(.*?)$/) ? ($1, $2) : ('',  
$subname);
-        $sub_links .= sprintf qq{<td class="sub_pkg">%s</td>}, $pkg;

          # remove OWN filename from eg __ANON__[(eval  
3)[/long/path/name.pm:99]:53]
          #                     becomes __ANON__[(eval 3)[:99]:53]
-        # XXX doesn't always work right because $filestr isn't full  
filename
+        # XXX doesn't work right if $filestr isn't full filename
          $subr =~ s/\Q$filestr\E:(\d+)/:$1/g;
          # remove @INC prefix from other paths
          $subr =~ s/$inc_path_regex//;    # for __ANON__[/very/long/path...]

-        my $first_line = $sub->first_line;
-        my $fileinfo   = $sub->fileinfo;
-        if ($fileinfo and my ($outer_fileinfo, $outer_line) =  
$fileinfo->outer) {    # eval
-            $fileinfo   = $outer_fileinfo;
-            $first_line = $outer_line;
-        }
+        $sub_links .= qq{<td class="sub_name">};
+        # hidden span is for tablesorter to sort on
+        $sub_links .= sprintf(qq{<span style="display:  
none;">%s::%s</span>}, $pkg, $subr);

          my $href = $reporter->href_for_sub($subname);
-        $sub_links .= sprintf( qq{<td class="sub_sub"><a %s>%s</a>%s</td>},
-            $href, $subr, $sub->is_xsub ? " (xsub)" : ""
+        $sub_links .= sprintf(qq{%*s<a %s>%s</a>%s</span></td>},
+            $max_pkg_name_len+2, $pkg, $href, $subr, $sub->is_xsub ? "  
(xsub)" : ""
          );

          $sub_links .= "</tr>\n";
@@ -242,13 +239,13 @@
          </tbody>
          </table>
      };
-    # sort on 4th col (excl_time,desc) then 6th (pkg) and 7th (name)
+    # sort on 4th col (excl_time,desc) then 6th (pkg+name)
      push @on_ready_js, q{
          $("#subs_table").tablesorter({
-            sortList: [[3,1],[5,0],[6,0]],
+            sortList: [[3,1]],
              headers: {
                  3: { sorter: 'fmt_time' },
-                4: { sorter: 'fmt_time' }
+                4: { sorter: 'fmt_time' },
              }
          });
      };
@@ -858,19 +855,22 @@
      <link rel="stylesheet" type="text/css"  
href="style.tablesorter.css"></link>
      <script type="text/javascript">
      // add parser through the tablesorter addParser method
-    \$.tablesorter.addParser({
+    \$.tablesorter.addParser({
          id: 'fmt_time',   // name of this parser
          is: function(s) {
              return false; // return false so this parser is not auto  
detected
          },
          format: function(orig) { // format data for normalization
              // console.log(orig);
+            var val = orig.replace(/s/,'');
+            if (val != orig) { return val; }
              var val = orig.replace(/ms/,'');
              if (val != orig) { return val / (1000); }
              val = orig.replace(/µs/,''); /* XXX use &micro; ? */
              if (val != orig) { return val / (1000*1000); }
              val = orig.replace(/ns/,'');
              if (val != orig) { return val / (1000*1000*1000); }
+            if (orig == '0') { return orig; }
              console.log('no match for fmt_time of '.concat(orig));
              return orig;
          },
@@ -1047,34 +1047,11 @@
  }

  /* subroutine dispatch table */
-td.sub_pkg {
-  text-align: right;
-  padding-right: 0;
-  border-right: hidden;
-  font-family: monospace;
-  color: gray;
-}
-td.sub_sub {
+.sub_name {
    text-align: left;
-  padding-left: 0;
-  border-left: hidden;
    font-family: monospace;
-}
-
-a.sub_sub:link {
-  color: blue;
-  text-decoration: none;
-}
-
-a.sub_sub:hover,
-a.sub_sub:visited:hover {
-  text-decoration: underline;
-}
-
-a.sub_sub:visited,
-a.sub_sub:active {
-  color: blue;
-  text-decoration: none;
+  white-space: pre;
+  color: gray;
  }

  /* source code */

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