BIND 10 trac2042, updated. c8795d7621af446a30a9cb6db6e90b0f04d485e4 [2042] Time measurements implemented.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jul 11 15:48:20 UTC 2012


The branch, trac2042 has been updated
       via  c8795d7621af446a30a9cb6db6e90b0f04d485e4 (commit)
      from  4f08254003eb525073f88a2dd6181deb66469f3a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c8795d7621af446a30a9cb6db6e90b0f04d485e4
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Jul 11 17:48:02 2012 +0200

    [2042] Time measurements implemented.

-----------------------------------------------------------------------

Summary of changes:
 tests/tools/dhcp-ubench/mysql_ubench.cc |   36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

-----------------------------------------------------------------------
diff --git a/tests/tools/dhcp-ubench/mysql_ubench.cc b/tests/tools/dhcp-ubench/mysql_ubench.cc
index 6bce65a..c6f9c02 100644
--- a/tests/tools/dhcp-ubench/mysql_ubench.cc
+++ b/tests/tools/dhcp-ubench/mysql_ubench.cc
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <time.h>
 #include <mysql/mysql.h>
 
 using namespace std;
@@ -135,19 +136,52 @@ bool deleteLease4Test(MYSQL* conn, uint32_t num) {
     }
 }
 
+void print_clock(const std::string& operation, uint32_t num,
+                 const struct timespec& before,
+                 const struct timespec& after) {
+    long int tv_sec = after.tv_sec - before.tv_sec;
+
+    long int tv_nsec = after.tv_nsec - before.tv_nsec;
+
+    cout << "after.tv_nsec=" << after.tv_nsec
+         << " before.tv_nsec=" << before.tv_nsec << endl;
+
+    if (tv_nsec < 0) {
+        tv_sec++;
+        tv_nsec += 1000000000; // 10^9
+    }
+
+    double oneoper = (tv_nsec/1000 + tv_sec*1000000)/num;
+
+    cout << "Operation " << operation << " repeated " << num << " times took "
+         << tv_sec << " seconds, " << tv_nsec/1000 << " us, 1 operation took "
+         << oneoper << "us" << endl;
+
+}
+
 int main(int argc, const char * argv[]) {
 
     cout << "MySQL client version is " << mysql_get_client_info() << endl;
 
     uint32_t num = 100;
+    struct timespec ts[5];
 
     try {
         MYSQL *conn = connect();
 
+        clock_gettime(CLOCK_REALTIME, &ts[0]);
+
         createLease4Test(conn, num);
+        clock_gettime(CLOCK_REALTIME, &ts[1]);
+
         searchLease4Test(conn, num);
+        clock_gettime(CLOCK_REALTIME, &ts[2]);
+
         updateLease4Test(conn, num);
+        clock_gettime(CLOCK_REALTIME, &ts[3]);
+
         deleteLease4Test(conn, num);
+        clock_gettime(CLOCK_REALTIME, &ts[4]);
 
         disconnect(conn);
 
@@ -156,5 +190,7 @@ int main(int argc, const char * argv[]) {
         return (-1);
     }
 
+    print_clock("Create leases4 ", num, ts[0], ts[1]);
+
     return (0);
 }



More information about the bind10-changes mailing list