BIND 10 trac2040, updated. 272d9f6f5bb929d81f1236ad953378d145225ade [2040] DHCP benchmarks now compile on Mac OS

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Aug 22 03:13:28 UTC 2012


The branch, trac2040 has been updated
       via  272d9f6f5bb929d81f1236ad953378d145225ade (commit)
      from  5c8635b42e86fd2e9c95ed4205457249c394cbed (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 272d9f6f5bb929d81f1236ad953378d145225ade
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Aug 22 05:09:49 2012 +0200

    [2040] DHCP benchmarks now compile on Mac OS

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

Summary of changes:
 tests/tools/dhcp-ubench/Makefile        |   14 ++++++++++--
 tests/tools/dhcp-ubench/benchmark.cc    |   37 ++++++++++++++++++++++++++-----
 tests/tools/dhcp-ubench/benchmark.h     |    8 ++++---
 tests/tools/dhcp-ubench/mysql_ubench.cc |    2 +-
 4 files changed, 50 insertions(+), 11 deletions(-)

-----------------------------------------------------------------------
diff --git a/tests/tools/dhcp-ubench/Makefile b/tests/tools/dhcp-ubench/Makefile
index 4944f52..4be8fe7 100644
--- a/tests/tools/dhcp-ubench/Makefile
+++ b/tests/tools/dhcp-ubench/Makefile
@@ -1,11 +1,21 @@
+# Linux switches
 CFLAGS=-g -O0 -Wall -pedantic -Wextra
+
+# Mac OS: We don't use pedantic as Mac OS version of MySQL (5.5.24) does use long long (not part of ISO C++)
+#CFLAGS=-g -O0 -Wall -Wextra -I/opt/local/include
+
+# Mac OS does not require -lrt
+# Linux requires -lrt
 LDFLAGS=-lrt
 
 MEMFILE_CFLAGS=
 MEMFILE_LDFLAGS=
 
-MYSQL_CFLAGS=`mysql_config --cflags`
-MYSQL_LDFLAGS=`mysql_config --libs`
+# It is mysql_config on most Linux systems and mysql_config5 on Mac OS
+MYSQL_CONFIG=mysql_config
+
+MYSQL_CFLAGS=`$(MYSQL_CONFIG) --cflags`
+MYSQL_LDFLAGS=`$(MYSQL_CONFIG) --libs`
 
 SQLITE_CFLAGS=`pkg-config sqlite3 --cflags`
 SQLITE_LDFLAGS=`pkg-config sqlite3 --libs`
diff --git a/tests/tools/dhcp-ubench/benchmark.cc b/tests/tools/dhcp-ubench/benchmark.cc
index 50f3aaa..8e67c7f 100644
--- a/tests/tools/dhcp-ubench/benchmark.cc
+++ b/tests/tools/dhcp-ubench/benchmark.cc
@@ -18,6 +18,15 @@
 #include <boost/lexical_cast.hpp>
 #include "benchmark.h"
 
+// The following headers are for getting precise time (clock_gettime on Linux or that mac os thingie)
+#include <time.h>
+#include <sys/time.h>
+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#endif
+
+
 using namespace std;
 
 uBenchmark::uBenchmark(uint32_t iterations, const std::string& dbname,
@@ -140,19 +149,19 @@ int uBenchmark::run() {
     try {
         connect();
 
-        clock_gettime(CLOCK_REALTIME, &ts_[0]);
+        ts_[0] = get_time();
 
         createLease4Test();
-        clock_gettime(CLOCK_REALTIME, &ts_[1]);
+        ts_[1] = get_time();
 
         searchLease4Test();
-        clock_gettime(CLOCK_REALTIME, &ts_[2]);
+        ts_[2] = get_time();
 
         updateLease4Test();
-        clock_gettime(CLOCK_REALTIME, &ts_[3]);
+        ts_[3] = get_time();
 
         deleteLease4Test();
-        clock_gettime(CLOCK_REALTIME, &ts_[4]);
+        ts_[4] = get_time();
 
         disconnect();
 
@@ -168,3 +177,21 @@ int uBenchmark::run() {
 
     return (0);
 }
+
+struct timespec uBenchmark::get_time() {
+    struct timespec ts;
+
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+    clock_serv_t cclock;
+    mach_timespec_t mts;
+    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+    clock_get_time(cclock, &mts);
+    mach_port_deallocate(mach_task_self(), cclock);
+    ts.tv_sec = mts.tv_sec;
+    ts.tv_nsec = mts.tv_nsec;
+#else
+    clock_gettime(CLOCK_REALTIME, &ts);
+#endif
+
+    return ts;
+}
diff --git a/tests/tools/dhcp-ubench/benchmark.h b/tests/tools/dhcp-ubench/benchmark.h
index c126de3..6fee870 100644
--- a/tests/tools/dhcp-ubench/benchmark.h
+++ b/tests/tools/dhcp-ubench/benchmark.h
@@ -172,6 +172,9 @@ protected:
     /// @brief prints out command-line help (list of parameters + version)
     void usage();
 
+    /// @brief a wrapper around OS-specific method for getting time
+    struct timespec get_time();
+
     /// Number of operations (e.g. insert lease num times)
     uint32_t num_;
 
@@ -189,9 +192,8 @@ protected:
 
     /// @brief hit ratio for search test (must be between 0.0 and 1.0)
     ///
-    /// This parameter is used in seatch. The formula causes the search
-    /// to find something a lease in 90% cases of hit ratio is 0.9.
-    ///
+    /// This parameter is used in search benchmark. The formula causes the
+    /// search to find something a lease in 90% cases of hit ratio is 0.9.
     float hitratio_;
 
     /// benchmarks must generate the leases starting from 1.0.0.0 address
diff --git a/tests/tools/dhcp-ubench/mysql_ubench.cc b/tests/tools/dhcp-ubench/mysql_ubench.cc
index 0351c99..ca1984c 100644
--- a/tests/tools/dhcp-ubench/mysql_ubench.cc
+++ b/tests/tools/dhcp-ubench/mysql_ubench.cc
@@ -18,7 +18,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
-#include <mysql/mysql.h>
+#include <mysql.h>
 
 #include "benchmark.h"
 #include "mysql_ubench.h"



More information about the bind10-changes mailing list