Revision: 1246
Author: [email protected]
Date: Thu May 27 06:24:46 2010
Log: Better handling of profile data for line 0 (ie data that we couldn't associate with a line).
Now shows up as an extra first line of the report.

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

Modified:
 /trunk/Changes
 /trunk/lib/Devel/NYTProf/Reader.pm

=======================================
--- /trunk/Changes      Thu May 27 02:40:28 2010
+++ /trunk/Changes      Thu May 27 06:24:46 2010
@@ -11,7 +11,6 @@
 subroutine profiler docs need update
 add u key to treemap to trigger moving 'up' a level
 add "calls N subs" to treemap mouseover box
-string eval merging - must allow at least viewing of source for called subs defined in a nested eval

 =head2 Changes in Devel::NYTProf 3.12 (svn 1194) 22nd April 2010

@@ -22,10 +21,14 @@

   Added profile reporting of code executed in string evals.
     Each string eval executed gets it's own report page.
+    You can 'see' the code that was executed, with profile info.
     String evals may be collapsed/merged in some cases.

   Improved many sub-optimal behaviours related to string evals.

+  Profile data that couldn't be associated with a specific line,
+    such as calls made by perl to END blocks, is now shown in reports.
+
   Enabled savesrc=1 by default.

 Other changes:
=======================================
--- /trunk/lib/Devel/NYTProf/Reader.pm  Wed May 26 15:11:43 2010
+++ /trunk/lib/Devel/NYTProf/Reader.pm  Thu May 27 06:24:46 2010
@@ -376,18 +376,33 @@
             $src_lines = [ $msg ];
             $LINE = 0; # start numbering from 0 to flag fake contents
         }
+
+ # Since we use @$src_lines to drive the report generation, pad the array to + # ensure it has enough lines to include all the available profile info.
+        # Then the report is still useful even if we have no source code.
+ $src_lines->[$_] ||= '' for @$src_lines-1 .. $max_linenum-1; # grow array

         if (my $z = $stats_by_line{0}) {
-            warn "$filestr has stats_by_line for line 0! @{[ %$z ]}\n";
-            warn "0: @{[ map { $_->subname } @{ $z->{subdef_info} } ]}\n"
-                if $z->{subdef_info};
+            # typically indicates cases where we could do better
+            if ($trace || 1) {
+ warn "$filestr has unexpected info for line 0: @{[ %$z ]}\n"; + # sub defs: used to be xsubs but they're handled separately now
+                # so there are no known causes of this any more
+                if (my $i = $z->{subdef_info}) {
+                    warn "0: @{[ map { $_->subname } @$i ]}\n"
+                }
+                # sub calls: they're typically END blocks that appear to be
+                # invoked from the main .pl script perl ran.
+                # Also some BEGINs and things like main::CORE:ftfile
+                # (see CPANDB's cpangraph script for some examples)
+                if (my $i = $z->{subcall_info}) {
+ warn sprintf "0: called %20s %s\n", $_, join " ", @{ $i->{$_} }
+                        for sort keys %$i;
+                }
+            }
+
             $LINE = 0;
-        }
-
- # if we don't have source code, still pad out the lines to match the data we have - # so the report page gets generated with annotations and so is still of some use.
-        if (!...@$src_lines or !$LINE) {
-            $src_lines->[$_] ||= '' for 0..$max_linenum-1; # grow array
+ unshift @$src_lines, "Profile data that couldn't be associated with a specific line:";
         }

         my $line_sub = $self->{mk_report_source_line}

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