Author: tim.bunce
Date: Fri Nov 28 00:26:45 2008
New Revision: 626

Modified:
    trunk/bin/nytprofhtml
    trunk/lib/Devel/NYTProf/Reader.pm

Log:
Call footer callback when footer used - this fixes @on_ready_js
(we loose the old regex replacement, but that's not needed with a callback)
Subroutine table should only be sortable when all subs are included.
Fixed tablesorter parsed for fmt_time.


Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml       (original)
+++ trunk/bin/nytprofhtml       Fri Nov 28 00:26:45 2008
@@ -239,7 +239,8 @@
          </tbody>
          </table>
      };
-    # sort on 4th col (excl_time,desc) then 6th (pkg+name)
+
+    # make table sortable if it contains all the subs
      push @on_ready_js, q{
          $("#subs_table").tablesorter({
              headers: {
@@ -247,7 +248,7 @@
                  4: { sorter: 'fmt_time' },
              }
          });
-    };
+    } if @subs_to_show == @subs;

      return $sub_links;
  }
@@ -270,14 +271,11 @@
      }
  );

-$reporter->set_param(
-    'footer',
-    sub {
-        my ($profile, $filestr) = @_;
-        my $footer = get_footer($profile);
-        return "</tbody></table></div>$footer</body></html>";
-    }
-);
+$reporter->set_param( footer => sub {
+    my ($profile, $filestr) = @_;
+    my $footer = get_footer($profile);
+    return "</tbody></table></div>$footer</body></html>";
+} );

  $reporter->set_param(mk_report_source_line => \&mk_report_source_line);
  $reporter->set_param(mk_report_xsub_line   => \&mk_report_xsub_line  );
@@ -512,11 +510,9 @@
      print OUT subroutine_table($profile, 0, $max_subs, undef);
      if ($all_subs > $max_subs) {
          print OUT sprintf qq{<div class="table_footer">
-            For more information see all %d subroutines
-            <a href="%s">sorted by exclusive time</a>,
-            or <a href="%s">sorted by inclusive time</a>.
+            For more information see <a href="%s">all %d subroutines</a>  
(sortable)
              </div>
-        }, $all_subs, "index-subs-excl.html", "index-subs-incl.html";
+        }, "index-subs-excl.html", $all_subs;
      }

      print OUT file_table($profile, $stats, 1);
@@ -859,14 +855,14 @@
          },
          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); }
+            val = orig.replace(/µs/,''); /* XXX use &micro; ? */
+            if (val != orig) { return val / (1000*1000); }
+            var val = orig.replace(/ms/,'');
+            if (val != orig) { return val / (1000); }
+            var val = orig.replace(/s/,'');
+            if (val != orig) { return val; }
              if (orig == '0') { return orig; }
              console.log('no match for fmt_time of '.concat(orig));
              return orig;

Modified: trunk/lib/Devel/NYTProf/Reader.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Reader.pm   (original)
+++ trunk/lib/Devel/NYTProf/Reader.pm   Fri Nov 28 00:26:45 2008
@@ -350,7 +350,6 @@

          # localize header and footer for variable replacement
          my $header    = $self->get_param('header',    [$profile, $filestr,  
$fname, $LEVEL]);
-        my $footer    = $self->get_param('footer',    [$profile,  
$filestr]);
          my $taintmsg  = $self->get_param('taintmsg',  [$profile,  
$filestr]);
          my $datastart = $self->get_param('datastart', [$profile,  
$filestr]);
          my $dataend   = $self->get_param('dataend',   [$profile,  
$filestr]);
@@ -365,7 +364,6 @@
                  # replace variable content
                  $replace = eval $replace;
                  $header    =~ s/$pattern/$replace/g;
-                $footer    =~ s/$pattern/$replace/g;
                  $taintmsg  =~ s/$pattern/$replace/g;
                  $datastart =~ s/$pattern/$replace/g;
                  $dataend   =~ s/$pattern/$replace/g;
@@ -442,7 +440,7 @@
          }

          print OUT $dataend;
-        print OUT $footer;
+        print OUT $self->get_param('footer', [$profile, $filestr]);
          close OUT;
      }
  }

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