Author: tim.bunce
Date: Fri Jan  2 14:15:06 2009
New Revision: 658

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

Log:
Add details of string evals to file table on index page.
Add $fi->number_of_statements_executed method - but it's not used yet
(awaiting deprecation of the old way of handling string evals in  
line_time_data)


Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml       (original)
+++ trunk/bin/nytprofhtml       Fri Jan  2 14:15:06 2009
@@ -740,6 +740,20 @@
      foreach my $filestats (sort { $b->{'time'} <=> $a->{'time'} }  
values %$stats) {
          my $fi = $profile->fileinfo_of($filestats->{filename})
              or die "Can't find fileinfo for $filestats->{filename}";
+        my @extra;
+
+        my $has_evals = $fi->has_evals(1) || [];
+        #my $eval_stmts = 0;
+        if (@$has_evals) {
+            my $n_evals = scalar @$has_evals;
+            my $msg = sprintf "executed %d string eval%s", $n_evals,  
($n_evals>1) ? "s" : "";
+            if (my @nested = grep { $_->eval_fid != $fi->fid }  
@$has_evals) {
+                $msg .= sprintf ": %d direct plus %d nested",
+                    $n_eva...@nested, scalar @nested;
+            }
+            push @extra, $msg;
+            #$eval_stmts += sum(map { $_->number_of_statements_executed }  
@$has_evals);
+        }

          print OUT qq{<tr class="index">};

@@ -763,8 +777,9 @@
          } qw(line block sub);
          print OUT "<td>$rep_links</td>";

-        print OUT sprintf q{<td><a name="f%s" title="%s">%s</a></td>},
-            $fi->fid, $fi->abs_filename, $fi->filename_without_inc;
+        print OUT sprintf q{<td><a name="f%s" title="%s">%s</a> %s</td>},
+            $fi->fid, $fi->abs_filename, $fi->filename_without_inc,
+            (@extra) ? sprintf("(%s)", join ", ", @extra) : "";
          print OUT "</tr>\n";
      }
      print OUT "</tbody>\n";

Modified: trunk/lib/Devel/NYTProf/FileInfo.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/FileInfo.pm (original)
+++ trunk/lib/Devel/NYTProf/FileInfo.pm Fri Jan  2 14:15:06 2009
@@ -14,6 +14,7 @@
      NYTP_SCi_INCL_UTIME NYTP_SCi_INCL_STIME NYTP_SCi_RECI_RTIME
  );

+
  sub filename  { shift->[NYTP_FIDi_FILENAME()] }
  sub eval_fid  { shift->[NYTP_FIDi_EVAL_FID()] }
  sub eval_line { shift->[NYTP_FIDi_EVAL_LINE()] }
@@ -71,6 +72,7 @@
      for (@$line_data) {
          next unless $_;
          $excl_time += $_->[0];
+        # XXX this old mechanism should be deprecated soon
          if (my $eval_lines = $_->[2]) {
              # line contains a string eval
              $excl_time += $_->[0] for values %$eval_lines;
@@ -78,6 +80,17 @@
      }
      return $excl_time;
  }
+
+
+sub number_of_statements_executed {
+    my ($self) = @_;
+    my $line_time_data = $self->line_time_data;
+    use Data::Dumper; warn Data::Dumper::Dumper($line_time_data);
+    my $stmts = 0;
+    $stmts += $_->[1]||0 for @$line_time_data;
+    return $stmts;
+}
+

  sub outer {
      my ($self, $recurse) = @_;

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