diff src/pt-binop.cc @ 12920:5d18231eee00

Extend profiling support to operators. * profiler.h: Always use std::string with profiler name instead of octave_function references for identifying functions. * profiler.cc: Adapt for that. * ov-builtin.cc: Ditto. * ov-mex-fcn.cc: Ditto. * ov-usr-fcn.cc: Ditto. * pt-binop.cc (tree_binary_expression::rvalue1): Collect profiler data. * pt-unop.cc (tree_prefix_expression::rvalue1): Ditto. (tree_postfix_expression::rvalue1): Ditto.
author Daniel Kraft <d@domob.eu>
date Fri, 29 Jul 2011 17:51:39 +0200
parents 46e0d66596f2
children 7820a12baadd
line wrap: on
line diff
--- a/src/pt-binop.cc
+++ b/src/pt-binop.cc
@@ -28,6 +28,7 @@
 #include "defun.h"
 #include "oct-obj.h"
 #include "ov.h"
+#include "profiler.h"
 #include "pt-binop.h"
 #include "pt-bp.h"
 #include "pt-walk.h"
@@ -120,6 +121,12 @@
 
           if (! error_state && b.is_defined ())
             {
+              profile_data_accumulator::enter pe (profiler,
+                                                  "binary " + oper ());
+
+              /* Note: The profiler does not catch the braindead-short-circuit
+                 evaluation code above.  But that should be ok.  */
+
               retval = ::do_binary_op (etype, a, b);
 
               if (error_state)
@@ -183,6 +190,11 @@
 
   bool result = false;
 
+  /* This evaluation is not caught by the profiler, since we can't find
+     a reasonable place where to time.  Note that we don't want to include
+     evaluation of LHS or RHS into the timing, but this is entangled
+     together with short-circuit evaluation here.  */
+
   if (op_lhs)
     {
       octave_value a = op_lhs->rvalue1 ();