Author: tim.bunce
Date: Mon Jul  6 02:23:29 2009
New Revision: 805

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

Log:
Added sysops=2 option to control how builtins are aggregated.
Added docs for sysops option.


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Mon Jul  6 02:23:29 2009
@@ -19,15 +19,15 @@
    Added interactive treemap view of package and subroutine times.
      Left-click to zoom in (drill-down) one level, right-click to zoom out.

-  Added sysops=1 option which enables profiling of perl opcodes
-    that make potentially slow system calls. They appear as xsubs
-    in the current package with names prefixed by "CORE:".
+  Added sysops=N option which enables profiling of perl opcodes
+    that make potentially slow system calls. They're treated as xsubs.

    Added log=F option to write trace log to a file.
    Added columns to the main source code reports to show
      a count of sub calls and time spent in those calls.

    Assorted cosmetic improvements.
+  Added docs describing how the subroutine profiler works.

  =head2 Changes in Devel::NYTProf 2.10 (svn r774) 18th June 2009


Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Mon Jul  6 02:23:29 2009
@@ -2328,8 +2328,15 @@
              */
              cv = NULL;
              is_xs = "sysop";
-            stash_name = CopSTASHPV(PL_curcop);
-            sv_setpvf(subname_sv, "%s::CORE:%s", stash_name,  
OP_NAME_safe(PL_op));
+            char *sysop_name = OP_NAME_safe(PL_op);
+            if (profile_sysops == 1) { /* 1 == put sysops into 1 package */
+                stash_name = "CORE";
+                sv_setpvf(subname_sv, "%s::%s", stash_name, sysop_name);
+            }
+            else {                     /* 2 == put sysops into multiple  
packages */
+                stash_name = CopSTASHPV(PL_curcop);
+                sv_setpvf(subname_sv, "%s::CORE:%s", stash_name,  
sysop_name);
+            }
              subname_pv = SvPV_nolen(subname_sv);
          }
          else {
@@ -2837,6 +2844,14 @@
  }


+/* Given a sub_name lookup the package name in pkg_fids_hv hash.
+ * pp_subcall_profiler() creates undef entries for a package the
+ * first time a sub in the package is called.
+ * Return Nullsv if there's no package name or no correponding entry
+ * else returns the SV.
+ * write_sub_line_ranges() updates the SV with the filename associated
+ * with the package, or at least its best guess.
+ */
  static SV *
  sub_pkg_filename_sv(pTHX_ char *sub_name)
  {
@@ -2879,7 +2894,7 @@
          /* get sv for package-of-subname to filename mapping */
          SV *pkg_filename_sv = sub_pkg_filename_sv(aTHX_ sub_name);

-        /* ignore is package is not of interest, or filename is empty (xs)  
*/
+        /* ignore if package is not of interest, or filename is empty (xs)  
*/
          if (!pkg_filename_sv || !filename_len)
              continue;

@@ -2925,7 +2940,8 @@
              if (pkg_filename_sv && SvOK(pkg_filename_sv)) {
                  filename = SvPV(pkg_filename_sv, filename_len);
              if (trace_level >= 2)
-                logwarn("Sub %s is xsub, we'll associate it with  
filename %.*s\n", sub_name, (int)filename_len, filename);
+                logwarn("Sub %s is xsub, we'll associate it with  
filename %.*s\n",
+                    sub_name, (int)filename_len, filename);
              }
          }


Modified: trunk/lib/Devel/NYTProf.pm
==============================================================================
--- trunk/lib/Devel/NYTProf.pm  (original)
+++ trunk/lib/Devel/NYTProf.pm  Mon Jul  6 02:23:29 2009
@@ -380,6 +380,27 @@
  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 sysops=N
+
+Profile builtin opcodes that make systems calls ('sysops'). These include
+C<print>, C<read>, C<sysread>, C<socket> and many more.
+
+If C<N> is 0 then sysop profiling is disabled.
+
+If C<N> is 1 then all the builtins are treated as being defined in the  
C<CORE>
+package. So times for C<print> calls from anywhere in your code are merged  
and
+accounted for as calls to an xsub called C<CORE::print>.
+
+If C<N> is 2 then builtins are treated as being defined in the package that
+calls them. So calls to C<print> from package C<Foo> are treated as calls  
to an
+xsub called C<Foo::CORE:print>. Note the single colon after CORE.
+
+Default is 0 as this is a new feature and still somewhat experimental.
+The default may change to 2 in a future release.
+
+The opcodes are profiled using their internal names, so C<printf> is  
C<prtf>
+and the C<-x> file test is C<fteexec>. This is likely to change in future.
+
  =head2 usecputime=1

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

Modified: trunk/t/lib/NYTProfTest.pm
==============================================================================
--- trunk/t/lib/NYTProfTest.pm  (original)
+++ trunk/t/lib/NYTProfTest.pm  Mon Jul  6 02:23:29 2009
@@ -79,7 +79,7 @@
              for my $compress (@test_opt_compress) {
                  push @env_combinations, {
                      start      => 'init',
-                    sysops     => 1,
+                    sysops     => 2,
                      leave      => $leave,
                      use_db_sub => $use_db_sub,
                      savesrc    => $savesrc,

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