Author: tim.bunce
Date: Fri Nov 28 02:22:53 2008
New Revision: 627

Modified:
    trunk/Changes
    trunk/NYTProf.xs
    trunk/t/test20-streval.rdt

Log:
Time spent on statements in a string eval that was nested in another string  
eval
was not being counted at the outermost level, so was being lost.
(We'll need to drop the current way string eval times are handled
when we start reporting string evals just like normal files.)


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Fri Nov 28 02:22:53 2008
@@ -17,6 +17,8 @@

  Reporting:

+  Time spent within nested string evals is accounted for.
+
    Fixed searching @INC for source files for reports.

    Dramatically increased performance of nytprofhtml

Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Fri Nov 28 02:22:53 2008
@@ -2748,6 +2748,31 @@
          warn(": %s = '%s'\n", text, SvPV_nolen(value_sv));
  }

+static int
+eval_outer_fid(pTHX_
+    AV *fid_fileinfo_av,
+    unsigned int fid,
+    int recurse,
+    unsigned int *eval_file_num_ptr,
+    unsigned int *eval_line_num_ptr
+) {
+    AV *av;
+    SV *fid_info_rvav = *av_fetch(fid_fileinfo_av, fid, 1);
+    if (!SvROK(fid_info_rvav)) /* should never happen */
+        return 0;
+    av = (AV *)SvRV(fid_info_rvav);
+    fid = (unsigned int)SvUV(*av_fetch(av,NYTP_FIDi_EVAL_FID,1));
+    if (!fid)
+        return 0;
+    if (eval_file_num_ptr)
+        *eval_file_num_ptr = fid;
+    if (eval_line_num_ptr)
+        *eval_line_num_ptr = (unsigned  
int)SvUV(*av_fetch(av,NYTP_FIDi_EVAL_LINE,1));
+    if (recurse)
+        eval_outer_fid(aTHX_ fid_fileinfo_av, fid, recurse,  
eval_file_num_ptr, eval_line_num_ptr);
+    return 1;
+}
+

  /**
   * Process a profile output file and return the results in a hash like
@@ -2922,17 +2947,14 @@
                  seconds  = (NV)ticks / ticks_per_sec;

                  fid_info_rvav = *av_fetch(fid_fileinfo_av, file_num, 1);
-                if (!SvROK(fid_info_rvav)) {
-                    /* only warn once */
-                    if (!SvOK(fid_info_rvav)) {
+                if (!SvROK(fid_info_rvav)) {    /* should never happen */
+                    if (!SvOK(fid_info_rvav)) { /* only warn once */
                          warn("Fid %u used but not defined", file_num);
                          sv_setsv(fid_info_rvav, &PL_sv_no);
                      }
                  }
                  else {
-                    AV *fid_av = (AV *)SvRV(fid_info_rvav);
-                    eval_file_num = (unsigned  
int)SvUV(*av_fetch(fid_av,1,1));
-                    eval_line_num = (unsigned  
int)SvUV(*av_fetch(fid_av,2,1));
+                    eval_outer_fid(aTHX_ fid_fileinfo_av, file_num, 1,  
&eval_file_num, &eval_line_num);
                  }

                  if (eval_file_num) {              /* fid is an eval */
@@ -2942,9 +2964,9 @@
                  }
                  if (trace_level >= 3) {
                      char *new_file_name = "";
-                    if (file_num != last_file_num && SvOK(fid_info_rvav))
-                        new_file_name = SvPV_nolen(*av_fetch((AV  
*)SvRV(fid_info_rvav), 0, 1));
-                    warn("Read %d:%-4d %2u ticks%s%s\n",
+                    if (file_num != last_file_num && SvROK(fid_info_rvav))
+                        new_file_name = SvPV_nolen(*av_fetch((AV  
*)SvRV(fid_info_rvav), NYTP_FIDi_FILENAME, 1));
+                    warn("Read %d:%-4d %2u ticks%s %s\n",
                          file_num, line_num, ticks, trace_note,  
new_file_name);
                  }


Modified: trunk/t/test20-streval.rdt
==============================================================================
--- trunk/t/test20-streval.rdt  (original)
+++ trunk/t/test20-streval.rdt  Fri Nov 28 02:22:53 2008
@@ -22,10 +22,7 @@
  fid_block_time        1       11      2       1       [ 0 2 ]
  fid_block_time        1       14      0       0
  fid_block_time        1       14      1       1
-fid_block_time 1       14      2       1       [ 0 1 ]
-fid_block_time 5       1       0       0
-fid_block_time 5       1       1       0
-fid_block_time 5       1       2       1       [ 0 1 ]
+fid_block_time 1       14      2       1       [ 0 2 ]
  fid_fileinfo  1       [ /.../test20-streval.p   1 2 0 0 ]
  fid_fileinfo  2       [ (eval 0)[test20-streval.p:8] 1 8 2 2 0 0 ]
  fid_fileinfo  3       [ (eval 0)[test20-streval.p:11] 1 11 3 2 0 0 ]
@@ -42,10 +39,7 @@
  fid_line_time 1       11      2       1       [ 0 2 ]
  fid_line_time 1       14      0       0
  fid_line_time 1       14      1       1
-fid_line_time  1       14      2       1       [ 0 1 ]
-fid_line_time  5       1       0       0
-fid_line_time  5       1       1       0
-fid_line_time  5       1       2       1       [ 0 1 ]
+fid_line_time  1       14      2       1       [ 0 2 ]
  fid_sub_time  1       3       [ 0 4 ]
  fid_sub_time  1       5       [ 0 1 ]
  fid_sub_time  1       8       0       0
@@ -56,10 +50,7 @@
  fid_sub_time  1       11      2       1       [ 0 2 ]
  fid_sub_time  1       14      0       0
  fid_sub_time  1       14      1       1
-fid_sub_time   1       14      2       1       [ 0 1 ]
-fid_sub_time   5       1       0       0
-fid_sub_time   5       1       1       0
-fid_sub_time   5       1       2       1       [ 0 1 ]
+fid_sub_time   1       14      2       1       [ 0 2 ]
  profile_modes fid_block_time  block
  profile_modes fid_line_time   line
  profile_modes fid_sub_time    sub

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