Author: tim.bunce
Date: Wed Jul 15 05:44:35 2009
New Revision: 828

Modified:
    trunk/Changes
    trunk/NYTProf.xs
    trunk/bin/nytprofhtml
    trunk/lib/Devel/NYTProf.pm
    trunk/t/lib/NYTProfTest.pm
    trunk/t/test60-subname.p

Log:
Renamed sysops option to slowops and added match and subst (s/// & m//)  
opcodes.
Fixed presentation of xsub stubs in nytprofhtml.


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Wed Jul 15 05:44:35 2009
@@ -6,7 +6,7 @@

  =head2 Changes in Devel::NYTProf 2.11

-XXX sysops needs docs and more ops
+XXX slowops needs docs and more ops
  XXX subroutine profiler docs need update

    Note: The file format has changed. Old files can't be read.
@@ -21,11 +21,10 @@

    Added log=F option to write trace log to a file.

-  Added sysops=N option which enables profiling of perl opcodes
-    that make potentially slow system calls ("system call opcodes")
-    like sleep, stat, read, write etc.  They're treated like xsubs.
-    sysops=1 puts timings into one package ("CORE::", eg CORE::sleep)
-    sysops=1 puts timings into into the package that made the
+  Added slowops=N option which enables profiling of potentially slow
+    perl opcodes (e.g., system calls and regexs). They're treated like  
xsubs.
+    slowops=1 puts timings into one package ("CORE::", eg CORE::sleep)
+    slowops=2 puts timings into into the package that made the
      call, e.g., "Foo::CORE:sleep" (note the single colon).

  Changes to subroutine profiler:

Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Wed Jul 15 05:44:35 2009
@@ -243,8 +243,8 @@
      { "clock", -1 },
  #define profile_stmts options[9].option_value
      { "stmts", 1 },                              /* statement exclusive  
times */
-#define profile_sysops options[10].option_value
-    { "sysops", 0 }                              /* opcodes that make slow  
system calls */
+#define profile_slowops options[10].option_value
+    { "slowops", 0 }                                /* slow opcodes,  
typically system calls */
  };

  /* time tracking */
@@ -2183,7 +2183,7 @@
              av_store(av, NYTP_SCi_CALL_COUNT, newSVuv(0));
              sv_setsv(*hv_fetch(hv, "[0:0]", 5, 1), newRV_noinc((SV *)av));

-            if (   ('s' == *subr_entry->called_is_xs) /* "sop" (sysop) */
+            if (   ('s' == *subr_entry->called_is_xs) /* "sop" (slowop) */
                  || (subr_entry->called_cv && SvTYPE(subr_entry->called_cv)  
== SVt_PVCV)
              ) {
                  /* We just use an empty string as the filename for xsubs
@@ -2365,19 +2365,19 @@
  }

  static OP *
-pp_sysop_profiler(pTHX)
+pp_slowop_profiler(pTHX)
  {
      return pp_subcall_profiler(aTHX_ 1);
  }

  static OP *
-pp_subcall_profiler(pTHX_ int is_sysop)
+pp_subcall_profiler(pTHX_ int is_sop)
  {
      OP *op;
      COP *prev_cop = PL_curcop;                    /* not PL_curcop_nytprof  
here */
      OP *next_op = PL_op->op_next;                 /* op to execute after  
sub returns */
      /* pp_entersub can be called with PL_op->op_type==0 */
-    OPCODE op_type = (is_sysop) ? PL_op->op_type : OP_ENTERSUB;
+    OPCODE op_type = (is_sop) ? PL_op->op_type : OP_ENTERSUB;
      dSP;
      I32 save_ix;
      SV *sub_sv;
@@ -2451,7 +2451,7 @@
       * first op *within* the sub (typically a nextstate/dbstate).
       * For XS subs, pp_entersub executes the entire sub
       * and returns the op *after* the sub (PL_op->op_next).
-     * Other ops we profile (eg sysops) act like xsubs.
+     * Other ops we profile (eg slowops) act like xsubs.
       * This call may exit via an exception, in which case the
       * block below doesn't get executed.
       */
@@ -2472,22 +2472,22 @@


          called_subnam_sv = newSV(0);
-        if (is_sysop) {
+        if (is_sop) {
              /* pretend builtins are xsubs in the same package
              * but with "CORE:" (one colon) prepended to the name.
              */
-            const char *sysop_name = OP_NAME_safe(PL_op);
+            const char *slowop_name = OP_NAME_safe(PL_op);
              called_cv = NULL;
              is_xs = "sop";
-            if (profile_sysops == 1) { /* 1 == put sysops into 1 package */
+            if (profile_slowops == 1) { /* 1 == put slowops into 1 package  
*/
                  stash_name = "CORE";
-                sv_setpv(called_subnam_sv, sysop_name);
+                sv_setpv(called_subnam_sv, slowop_name);
              }
-            else {                     /* 2 == put sysops into multiple  
packages */
+            else {                     /* 2 == put slowops into multiple  
packages */
                  stash_name = CopSTASHPV(PL_curcop);
-                sv_setpvf(called_subnam_sv, "CORE:%s", sysop_name);
+                sv_setpvf(called_subnam_sv, "CORE:%s", slowop_name);
              }
-            subr_entry->called_cv_depth = 1; /* an approximation for  
sysops */
+            subr_entry->called_cv_depth = 1; /* an approximation for  
slowops */
          }
          else {
              if (op != next_op) {   /* have entered a sub */
@@ -2804,7 +2804,7 @@
          }
      }

-    if (profile_sysops) {
+    if (profile_slowops) {
          /* possible list of sys ops to profile:
              sysopen open close readline rcatline getc read
              print prtf sysread syswrite send recv
@@ -2831,19 +2831,21 @@
          /* XXX this will turn into a loop over an array that maps
           * opcodes to the subname we'll use: OP_PRTF => "printf"
           */
-        PL_ppaddr[OP_SLEEP] = pp_sysop_profiler;
-        PL_ppaddr[OP_OPEN] = pp_sysop_profiler;
-        PL_ppaddr[OP_CLOSE] = pp_sysop_profiler;
-        PL_ppaddr[OP_READ] = pp_sysop_profiler;
-        PL_ppaddr[OP_READLINE] = pp_sysop_profiler;
-        PL_ppaddr[OP_STAT] = pp_sysop_profiler;
-        PL_ppaddr[OP_OPEN_DIR] = pp_sysop_profiler;
-        PL_ppaddr[OP_CLOSEDIR] = pp_sysop_profiler;
-        PL_ppaddr[OP_READDIR] = pp_sysop_profiler;
-        PL_ppaddr[OP_RAND] = pp_sysop_profiler;
-        PL_ppaddr[OP_SRAND] = pp_sysop_profiler;
-        PL_ppaddr[OP_WAIT] = pp_sysop_profiler;
-        PL_ppaddr[OP_SELECT] = pp_sysop_profiler;
+        PL_ppaddr[OP_SLEEP] = pp_slowop_profiler;
+        PL_ppaddr[OP_OPEN] = pp_slowop_profiler;
+        PL_ppaddr[OP_CLOSE] = pp_slowop_profiler;
+        PL_ppaddr[OP_READ] = pp_slowop_profiler;
+        PL_ppaddr[OP_READLINE] = pp_slowop_profiler;
+        PL_ppaddr[OP_STAT] = pp_slowop_profiler;
+        PL_ppaddr[OP_OPEN_DIR] = pp_slowop_profiler;
+        PL_ppaddr[OP_CLOSEDIR] = pp_slowop_profiler;
+        PL_ppaddr[OP_READDIR] = pp_slowop_profiler;
+        PL_ppaddr[OP_RAND] = pp_slowop_profiler;
+        PL_ppaddr[OP_SRAND] = pp_slowop_profiler;
+        PL_ppaddr[OP_WAIT] = pp_slowop_profiler;
+        PL_ppaddr[OP_SELECT] = pp_slowop_profiler;
+        PL_ppaddr[OP_MATCH] = pp_slowop_profiler;
+        PL_ppaddr[OP_SUBST] = pp_slowop_profiler;
      }

      /* redirect opcodes for caller tracking */

Modified: trunk/bin/nytprofhtml
==============================================================================
--- trunk/bin/nytprofhtml       (original)
+++ trunk/bin/nytprofhtml       Wed Jul 15 05:44:35 2009
@@ -451,7 +451,7 @@
      (my $anchor = $subname) =~ s/\W/_/g;
      return join "",
          sprintf(qq{<tr><td class="h"><a name="%s"></a>%s</td>},  
$anchor, ''),
-        "<td></td><td></td><td></td>",
+        "<td></td><td></td><td></td><td></td><td></td>",
          report_src_line(undef, undef, $line, $profile, $subs_defined,  
$makes_calls_to, $filestr),
          "</tr>\n";
  }

Modified: trunk/lib/Devel/NYTProf.pm
==============================================================================
--- trunk/lib/Devel/NYTProf.pm  (original)
+++ trunk/lib/Devel/NYTProf.pm  Wed Jul 15 05:44:35 2009
@@ -380,12 +380,13 @@
  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
+=head2 slowops=N

-Profile builtin opcodes that make systems calls ('sysops'). These include
-C<print>, C<read>, C<sysread>, C<socket> and many more.
+Profile perl opcodes that can be slow. These include opcodes that make  
system
+calls, such as C<print>, C<read>, C<sysread>, C<socket> etc., plus regular
+expression opcodes like C<subst> and C<match>.

-If C<N> is 0 then sysop profiling is disabled.
+If C<N> is 0 then slowops 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
@@ -398,7 +399,7 @@
  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>
+The opcodes are currently 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

Modified: trunk/t/lib/NYTProfTest.pm
==============================================================================
--- trunk/t/lib/NYTProfTest.pm  (original)
+++ trunk/t/lib/NYTProfTest.pm  Wed Jul 15 05:44:35 2009
@@ -86,7 +86,7 @@
              for my $compress (@test_opt_compress) {
                  push @env_combinations, {
                      start      => 'init',
-                    sysops     => 2,
+                    slowops    => 2,
                      leave      => $leave,
                      use_db_sub => $use_db_sub,
                      savesrc    => $savesrc,

Modified: trunk/t/test60-subname.p
==============================================================================
--- trunk/t/test60-subname.p    (original)
+++ trunk/t/test60-subname.p    Wed Jul 15 05:44:35 2009
@@ -18,7 +18,7 @@
  my $subname = "Devel::NYTProf::Test::example_xsub";
  &$subname("foo");

-# call builtin (will be recorded if sysops=1 option set)
+# call builtin (will be recorded if slowops option set)
  wait();

  # XXX currently goto isn't noticed by the profiler

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