List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:October 30 2007 6:04pm
Subject:Rev 223: Added timing to async callbacks. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge

------------------------------------------------------------
revno: 223
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Tue 2007-10-30 18:04:07 +0000
message:
  Added timing to async callbacks.
modified:
  configure.in                   configure.in-20070228020914-u2pk759xg7thauwf-13
  java/com/mysql/cluster/ndbj/examples/TestEvent.java
testevent.java-20071026232217-5tigfbdmcudrnbbx-1
  java/ndbj.i                    ndbj.i-20070913223244-5938mztpztyn9sry-1
  swig/NdbTransaction.i          ndbtransaction.i-20070227184716-ecjyhh3jgvmye4de-7
  swig/ndbglobals.i              globals.i-20070228021421-qkr4cbpxymyqdrf3-7
=== modified file 'configure.in'
--- a/configure.in	2007-10-28 00:17:55 +0000
+++ b/configure.in	2007-10-30 18:04:07 +0000
@@ -6,6 +6,18 @@
     [  --with-debug         Build a debugging version],
     [with_debug=$withval],
     [with_debug=no])
+
+AC_ARG_WITH([async-time],
+  [AS_HELP_STRING([--with-async-time],
+      [Produce timing reports for Async transactions @<:@default=no@:>@])],
+    [with_asynctime=$withval],
+    [with_asynctime=no])
+
+AS_IF([test "x$with_asynctime" = "xyes"],
+      [AC_DEFINE([DEBUG_ASYNC_TIMES],1,
+	[Define to 1 if you want to profile async callbacks])],
+      [])
+
 if test "$with_debug" = "yes"
 then
   CXXFLAGS="-ggdb3 -Wall"

=== modified file 'java/com/mysql/cluster/ndbj/examples/TestEvent.java'
--- a/java/com/mysql/cluster/ndbj/examples/TestEvent.java	2007-10-28 00:05:03 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/TestEvent.java	2007-10-30 18:04:07 +0000
@@ -89,6 +89,8 @@
 	  }
       NdbResultSet theResultSet = eop.resultData();
       NdbResultSet preResultSet = eop.preResultData();
+     
+      
       
       System.out.println("done");
 

=== modified file 'java/ndbj.i'
--- a/java/ndbj.i	2007-10-29 17:52:57 +0000
+++ b/java/ndbj.i	2007-10-30 18:04:07 +0000
@@ -41,6 +41,7 @@
 
 %{
 #include <stdio.h>
+#include "config.h"
 
 typedef struct
 asynch_callback_t

=== modified file 'swig/NdbTransaction.i'
--- a/swig/NdbTransaction.i	2007-10-23 05:12:33 +0000
+++ b/swig/NdbTransaction.i	2007-10-30 18:04:07 +0000
@@ -136,6 +136,9 @@
     void executeAsynchPrepare(ExecType execType,
 			      BaseCallback * cb,
 			      AbortOption abortOption = AbortOnError) {
+#ifdef DEBUG_ASYNC_TIMES
+    cb->setCreateTime();
+#endif
       self->executeAsynchPrepare(execType,theNdbCallback,(void *)cb,abortOption);
     };
 

=== modified file 'swig/ndbglobals.i'
--- a/swig/ndbglobals.i	2007-10-30 12:02:14 +0000
+++ b/swig/ndbglobals.i	2007-10-30 18:04:07 +0000
@@ -27,19 +27,44 @@
 #include <NdbApi.hpp> 
 //#include <m_ctype.h>
 
+
+  long long getTimeMicros() 
+  {
+    struct timeval tTime;
+    gettimeofday(&tTime, 0);
+    long long microSeconds = (long long) tTime.tv_sec * 1000000 + tTime.tv_usec;
+    return microSeconds;
+  }
+
   class BaseCallback { 
 
+
   public:
+    long long createTime;
+
     virtual ~BaseCallback() {};
     virtual void callback(int res, NdbTransaction * trans) { 
       printf("In BaseCallback::callback. Return Value: %d. Transaction: %p\n",res,trans);
-  }
+    }
+
+    void setCreateTime() { 
+      printf("In setCreateTime \n");
+      createTime = getTimeMicros();
+    }
+    long long getElapsedTime() { 
+      return getTimeMicros()-createTime; 
+    }
 
   };
 
   void theNdbCallback(int ret, NdbTransaction * trans, void * anyObject) {
     BaseCallback * cb = (BaseCallback *)anyObject;
     cb->callback(ret, trans);
+    #ifdef DEBUG_ASYNC_TIMES
+    long long elapsed = cb->getElapsedTime();
+    printf("Callback %p took %llu microseconds\n",cb,elapsed);
+    #endif
+
   }
 
   class BaseEventCallback {
@@ -58,13 +83,6 @@
     cb->callback(theOp,theNdb);
   }
 
-  long long getTimeMicros() 
-  {
-    struct timeval tTime;
-    gettimeofday(&tTime, 0);
-    long long microSeconds = (long long) tTime.tv_sec * 1000000 + tTime.tv_usec;
-    return microSeconds;
-  }
 
 
 typedef int voidint; 

Thread
Rev 223: Added timing to async callbacks. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmergeMonty Taylor30 Oct