Revision: 1281
Author: [email protected]
Date: Mon Jun  7 09:41:57 2010
Log: Add $fi->sibling_evals method and use to improve report output.
Including generating links to 'sibling evals'.
Fix compiled warning.

http://code.google.com/p/perl-devel-nytprof/source/detail?r=1281

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

=======================================
--- /trunk/NYTProf.xs   Mon Jun  7 08:43:22 2010
+++ /trunk/NYTProf.xs   Mon Jun  7 09:41:57 2010
@@ -1405,7 +1405,7 @@
             if (!is_preamble && op) {
                 /* warn() can't either, in the cases I've encountered */
                 logwarn("Unable to determine line number in %s (ssix%d)\n",
-                    OutCopFILE(cop), PL_scopestack_ix);
+                    OutCopFILE(cop), (int)PL_scopestack_ix);
                 if (trace_level > 5)
                     do_op_dump(1, PerlIO_stderr(), (OP*)cop);
             }
=======================================
--- /trunk/bin/nytprofhtml      Mon Jun  7 06:55:25 2010
+++ /trunk/bin/nytprofhtml      Mon Jun  7 09:41:57 2010
@@ -145,6 +145,21 @@
                     $reporter->href_for_file($fi->eval_fi, $fi->eval_line),
                     _escape_html($fi->eval_fi->filename), $fi->eval_line
             ];
+
+            my @sibling_html;
+            for my $e_fi ($fi->sibling_evals) {
+                if ($e_fi == $fi) {
+                    push @sibling_html, 1...@sibling_html;
+                }
+                else {
+                    push @sibling_html, sprintf qq{<a %s>%d</a>},
+                        $reporter->href_for_file($e_fi),
+                        1...@sibling_html;
+                }
+            }
+            push @intro_rows, [ "Sibling evals",
+                join ", ", @sibling_html
+            ] if @sibling_html >= 2;
         }

         my $intro_table = join "\n", map {
@@ -170,18 +185,31 @@
     'merged_fids',
     sub {
         my ($profile, $fi) = @_;
+
         my $merged_fids = $fi->meta->{merged_fids};
-        my $extra = '';
-        $extra = qq{
+        my $evals_shown = 1 + scalar @$merged_fids;
+
+        my @siblings = $fi->sibling_evals;
+ my $merged_siblings = sum(map { scalar @{$_->meta->{merged_fids}} } @siblings);
+        my $evals_total = @siblings + $merged_siblings;
+
+        my @msg;
+        push @msg, sprintf qq{
+ The data used to generate this report page was merged from %s<br />
+            of the string eval on line %d of %s.
+        },  ($evals_shown == $evals_total)
+                ? sprintf("all %d executions", $evals_shown)
+ : sprintf("%d of the %d executions", $evals_shown, $evals_total),
+            $fi->eval_line, $fi->eval_fi->filename;
+
+        push @msg, qq{
The source code shown below is the text of just one of the calls to the eval.<br />\n This report page might not make much sense because the argument source code of those eval calls varied.<br />\n
         } if $fi->meta->{merged_fids_src_varied};

         return sprintf qq{<br /><div class="warn_title">NOTE!</div>\n
- <div class="warn">The data used to generate this report page was merged from %d executions<br />
-            of the string eval on line %d of %s.<br />
-            %s</div>
- }, 1+scalar @$merged_fids, $fi->eval_line, $fi->eval_fi->filename, $extra;
+            <div class="warn">%s</div>
+        }, join "<br />", @msg;
     },
 );

=======================================
--- /trunk/lib/Devel/NYTProf/FileInfo.pm        Mon Jun  7 08:07:31 2010
+++ /trunk/lib/Devel/NYTProf/FileInfo.pm        Mon Jun  7 09:41:57 2010
@@ -66,6 +66,15 @@

     return @eval_fis;
 }
+
+
+sub sibling_evals {
+    my ($self) = @_;
+    my $parent_fi = $self->eval_fi
+        or return; # not an eval
+    my $eval_line = $self->eval_line;
+    return grep { $_->eval_line == $eval_line } $parent_fi->has_evals;
+}


 sub _nullify {

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