Author: tim.bunce
Date: Thu Nov 20 06:59:24 2008
New Revision: 618

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

Log:
Added savesrc=1 option to copy source code into the profile
so reports are not affected by changes to the source files.


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Thu Nov 20 06:59:24 2008
@@ -10,6 +10,9 @@
      so you can see more accurate statement execution counts
      for some kinds of constructs.

+  Added savesrc=1 option to copy source code into the profile
+    so reports are not affected by changes to the source files.
+
    Fixed searching @INC for source files for reports.

    Dramatically increased performance of nytprofhtml

Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Thu Nov 20 06:59:24 2008
@@ -66,6 +66,7 @@

  #define NYTP_OPTf_ADDPID         0x0001 /* append .pid to output filename  
*/
  #define NYTP_OPTf_OPTIMIZE       0x0002 /* affect $^P & 0x04 */
+#define NYTP_OPTf_SAVESRC        0x0004 /* copy source code lines into  
profile data */

  #define NYTP_FIDf_IS_PMC         0x0001 /* .pm probably really loaded  
as .pmc */
  #define NYTP_FIDf_VIA_STMT       0x0002 /* fid first seen by stmt profiler  
*/
@@ -1189,10 +1190,11 @@
          || (found->key_len > 10 && strnEQ(found->key, "/loader/0x", 10))
          || (found->key_len == 1 && strnEQ(found->key, "-",  1))
          || (found->key_len == 2 && strnEQ(found->key, "-e", 2))
+        || (profile_opts & NYTP_OPTf_SAVESRC)
          ) {
+            /* source only available if PERLDB_LINE or PERLDB_SAVESRC is  
true */
              src_av = GvAV(gv_fetchfile(found->key));
              if (!src_av && trace_level >= 3)
-                /* source lines are only saved if PERLDB_LINE is true */
                  warn("No source available for fid %d%s\n",
                      found->id, use_db_sub ? "" : ", set use_db_sub=1  
option");
          }
@@ -1756,6 +1758,11 @@
              ? profile_opts |  NYTP_OPTf_OPTIMIZE
              : profile_opts & ~NYTP_OPTf_OPTIMIZE;
      }
+    else if (strEQ(option, "savesrc")) {
+        profile_opts = (atoi(value))
+            ? profile_opts |  NYTP_OPTf_SAVESRC
+            : profile_opts & ~NYTP_OPTf_SAVESRC;
+    }
      else {
        struct NYTP_int_options_t *opt_p = options;
        const struct NYTP_int_options_t *const opt_end
@@ -1769,7 +1776,7 @@
            }
        } while (++opt_p < opt_end);
        if (!found) {
-           warn("Unknown NYTProf option: %s\n", option);
+           warn("Unknown NYTProf option: '%s'\n", option);
            return;
        }
      }

Modified: trunk/lib/Devel/NYTProf.pm
==============================================================================
--- trunk/lib/Devel/NYTProf.pm  (original)
+++ trunk/lib/Devel/NYTProf.pm  Thu Nov 20 06:59:24 2008
@@ -355,6 +355,22 @@
  compiled before NYTProf was loaded. So using use_db_sub=1 can be useful in
  cases where you can't load the profiler early in the life of the  
application.

+=head2 savesrc=1
+
+Save a copy of all source code into the profile data file. This makes the  
file
+self-contained, so the reporting tools no longer depend on having the  
original
+source code files available. So it also insulates you from later changes to
+those files that would normally make the reports out of sync with the data.
+
+By default NYTProf saved some source code: the arguments to the C<perl -e>
+option, the script fed to perl via STDIN when using C<perl ->, and the  
source
+code of string evals. (Currently string eval  source code isn't available  
in
+the reports. Patches welcome.)
+
+If you're using perl 5.10.0 or 5.8.8 (or earlier) then you need to also  
enable
+the C<use_db_sub=1> option otherwise perl doesn't make the source code
+available to NYTProf. Perl 5.8.9 and 5.10.1+ don't require that.
+
  =head2 usecputime=1

  Measure user CPU + system CPU time instead of the real elapsed 'wall clock'

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