Revision: 1200
Author: [email protected]
Date: Mon Apr 26 02:54:48 2010
Log: More string eval related polishing.

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

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

=======================================
--- /trunk/bin/nytprofhtml      Mon Apr 26 02:22:36 2010
+++ /trunk/bin/nytprofhtml      Mon Apr 26 02:54:48 2010
@@ -532,30 +532,38 @@
         my $evals_called_html = join "\n", map {
             my $eval_fi = $_;
             my $sum_of_stmts_time = $eval_fi->sum_of_stmts_time;
-            my $what = "string eval";
+            my ($what, $extra) = ("string eval", "");
+
+            my $merged_fids = $eval_fi->meta->{merged_fids};
+            if ($merged_fids) {
+                $extra .= sprintf " (data for these has been merged)";
+                $what .= "s";
+            }

             my @nested_evals = $eval_fi->has_evals(1);
-            my ($nest_eval_time, $extra) = (0, '');
+            my $nest_eval_time = 0;
             if (@nested_evals) {
$nest_eval_time = sum map { $_->sum_of_stmts_time } @nested_evals;
-
- $extra .= sprintf " (%s in this eval plus %s in %d nested evals)",
+                $extra .= sprintf ", %s here plus %s in %d nested evals",
fmt_time($sum_of_stmts_time), fmt_time($nest_eval_time),
                         scalar @nested_evals
                     if $nest_eval_time;
             }

-            my $merged_fids = $eval_fi->meta->{merged_fids};
-            if ($merged_fids) {
-                $extra .= sprintf " (data for these has been merged)";
-                $what .= "s";
+            if (my @subs_defined = $eval_fi->subs_defined(1)) {
+                my $sub_count  = @subs_defined;
+                my $call_count = sum map { $_->calls } @subs_defined;
+ $extra .= sprintf ". Times include %d call%s to %d sub%s defined herein.",
+                        $call_count, ($call_count != 1) ? 's' : '',
+                        $sub_count,  ($sub_count  != 1) ? 's' : ''
+                    if $call_count;
             }

my $link = sprintf(q{<a %s>%s</a>}, $reporter->href_for_file($eval_fi), $what); my $html = sprintf qq{%s# spent %s executing statements in %s%s%s},
                 $ws, fmt_time($sum_of_stmts_time+$nest_eval_time, 5),
- ($merged_fids) ? sprintf("%d ",1+scalar @$merged_fids) : '',
-                $link, $extra;
+ ($merged_fids) ? sprintf("%d ",1+scalar @$merged_fids) : '', $link,
+                $extra;

             $html;
         } @eval_fis;
=======================================
--- /trunk/lib/Devel/NYTProf/Data.pm    Wed Apr 21 06:41:34 2010
+++ /trunk/lib/Devel/NYTProf/Data.pm    Mon Apr 26 02:54:48 2010
@@ -134,7 +134,7 @@

         next if @$siblings == 1;

-        my @subs  = map { values %{ $_->subs } } @$siblings;
+        my @subs  = map { $_->subs_defined } @$siblings;
         my @calls = map { keys %{ $_->sub_call_lines } } @$siblings;
         my @evals = map { $_->has_evals(0) } @$siblings;
my $msg = sprintf "%d:%d: multiple evals (subs %d, calls %d, evals %d, fids: %s)",
@@ -652,7 +652,7 @@

     my $fi = $self->fileinfo_of($fid)
         or return;
-    my %subs = %{ $fi->subs || {} }; # shallow copy
+    my %subs = map { $_->subname => $_ } $fi->subs_defined;

     if ($incl_lines) {    # add in the first-line-number keys
         croak "Can't include line numbers without a fid" unless $fid;
=======================================
--- /trunk/lib/Devel/NYTProf/FileInfo.pm        Wed Apr 21 06:25:45 2010
+++ /trunk/lib/Devel/NYTProf/FileInfo.pm        Mon Apr 26 02:54:48 2010
@@ -88,16 +88,19 @@
 }


-# return a ref to a hash of { subname => subinfo, ... }
-sub subs      { shift->[NYTP_FIDi_SUBS_DEFINED()] } # deprecated
-
 # return subs defined as list of SubInfo objects
-# XXX add $include_evals arg?
 sub subs_defined {
-    return values %{ shift->[NYTP_FIDi_SUBS_DEFINED()] };
-}
+    my ($self, $incl_nested_evals) = @_;
+
+    return map { $_->subs_defined(0) } $self, $self->has_evals(1)
+        if $incl_nested_evals;
+
+    return values %{ $self->[NYTP_FIDi_SUBS_DEFINED()] };
+}
+
 sub subs_defined_sorted {
-    return sort { $a->subname cmp $b->subname } shift->subs_defined;
+    my ($self, $incl_nested_evals) = @_;
+ return sort { $a->subname cmp $b->subname } $self->subs_defined($incl_nested_evals);
 }


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