BIND 10 trac2042, updated. bd7de96f1b79572454747631197e35a887124571 [2042] MySQL update and delete benchmarks implemented.

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jul 12 12:59:11 UTC 2012


The branch, trac2042 has been updated
       via  bd7de96f1b79572454747631197e35a887124571 (commit)
      from  2aa180cfe8f08ea0a4b65a93b9a622343f1d4072 (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 bd7de96f1b79572454747631197e35a887124571
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Thu Jul 12 14:58:56 2012 +0200

    [2042] MySQL update and delete benchmarks implemented.

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

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

-----------------------------------------------------------------------
diff --git a/tests/tools/dhcp-ubench/mysql_ubench.cc b/tests/tools/dhcp-ubench/mysql_ubench.cc
index 436e27e..01f0577 100644
--- a/tests/tools/dhcp-ubench/mysql_ubench.cc
+++ b/tests/tools/dhcp-ubench/mysql_ubench.cc
@@ -55,9 +55,6 @@ void uBenchmark::print_clock(const std::string& operation, uint32_t num,
 
     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
@@ -98,9 +95,9 @@ int uBenchmark::run() {
     }
 
     print_clock("Create leases4 ", Num_, ts[0], ts[1]);
-    // print_clock("Search leases4 ", num, ts[1], ts[2]);
-    // print_clock("Update leases4 ", num, ts[2], ts[3]);
-    // print_clock("Delete leases4 ", num, ts[3], ts[4]);
+    print_clock("Search leases4 ", Num_, ts[1], ts[2]);
+    print_clock("Update leases4 ", Num_, ts[2], ts[3]);
+    print_clock("Delete leases4 ", Num_, ts[3], ts[4]);
 
     return (0);
 }
@@ -120,6 +117,9 @@ public:
     virtual void deleteLease4Test();
 
 protected:
+    const static bool CONFIRM_UPDATE = false;
+    const static bool CONFIRM_DELETE = false;
+
     void failure(const char* operation);
 
     std::string Hostname_;
@@ -200,6 +200,8 @@ void MySQL_uBenchmark::createLease4Test() {
     bool fqdn_fwd = true; // let's pretend to do AAAA update
     bool fqdn_rev = true; // let's pretend to do PTR update
 
+    printf("CREATE:   ");
+
     for (uint8_t i = 0; i < 20; i++) {
         hwaddr[i] = 65 + i;
     }
@@ -251,9 +253,12 @@ void MySQL_uBenchmark::searchLease4Test() {
     // this formula should roughly find something a lease in 90% cases
     float hitRatio = 0.9;
 
-    cout << "range=" << int(Num_ / hitRatio) << " minAddr=" << hex
+    /* cout << "range=" << int(Num_ / hitRatio) << " minAddr=" << hex
          << BASE_ADDR4 << " maxAddr=" << BASE_ADDR4 + int(Num_ / hitRatio)
-         << dec << endl;
+         << dec << endl; */
+
+    printf("RETRIEVE: ");
+
 
     for (uint32_t i = 0; i < Num_; i++) {
 
@@ -281,30 +286,115 @@ void MySQL_uBenchmark::searchLease4Test() {
             MYSQL_ROW row = mysql_fetch_row(result);
             // pretend to do something with it
 
-            printf("lease_id=%s addr=%s valid_lft=%s cltt=%s\n",
+            printf(".");
+            /* printf("lease_id=%s addr=%s valid_lft=%s cltt=%s\n",
                    (row[0]?row[0]:"NULL"),
                    (row[1]?row[1]:"NULL"),
                    (row[4]?row[4]:"NULL"),
-                   (row[5]?row[5]:"NULL"));
+                   (row[5]?row[5]:"NULL")); */
 
             mysql_free_result(result);
         } else {
-            printf("Address %x not found.\n", x);
+            // printf("Address %x not found.\n", x);
+            printf("x");
         }
-
     }
+
+    printf("\n");
 }
 
 void MySQL_uBenchmark::updateLease4Test() {
     if (!Conn_) {
         throw "Not connected to MySQL server.";
     }
+
+    printf("UPDATE:   ");
+
+    for (uint32_t i = 0; i < Num_; i++) {
+
+        uint32_t x = BASE_ADDR4 + random() % Num_;
+
+        char query[2000];
+        sprintf(query, "UPDATE lease4 SET valid_lft=1002, cltt=now() WHERE addr=%d", x);
+        mysql_real_query(Conn_, query, strlen(query));
+
+        MYSQL_RES * result = NULL;
+
+        if (CONFIRM_UPDATE) {
+            mysql_store_result(Conn_);
+
+            int num_rows = mysql_num_rows(result);
+            int num_fields = mysql_num_fields(result);
+
+            if ( (num_rows != 1) ) {
+                stringstream tmp;
+                tmp << "Search: DB returned " << num_rows << " leases for address "
+                    << hex << x << dec;
+                failure(tmp.str().c_str());
+            }
+
+            MYSQL_ROW row = mysql_fetch_row(result);
+            // pretend to do something with it
+
+            printf("lease_id=%s addr=%s valid_lft=%s cltt=%s\n",
+                   (row[0]?row[0]:"NULL"),
+                   (row[1]?row[1]:"NULL"),
+                   (row[4]?row[4]:"NULL"),
+                   (row[5]?row[5]:"NULL"));
+
+            mysql_free_result(result);
+        }
+        printf(".");
+    }
+
+    printf("\n");
 }
 
 void MySQL_uBenchmark::deleteLease4Test() {
     if (!Conn_) {
         throw "Not connected to MySQL server.";
     }
+
+    printf("DELETE:   ");
+
+    for (uint32_t i = 0; i < Num_; i++) {
+
+        uint32_t x = BASE_ADDR4 + i;
+
+        char query[2000];
+        sprintf(query, "DELETE FROM lease4 WHERE addr=%d", x);
+        mysql_real_query(Conn_, query, strlen(query));
+
+        MYSQL_RES * result = NULL;
+
+        if (CONFIRM_DELETE) {
+            mysql_store_result(Conn_);
+
+            int num_rows = mysql_num_rows(result);
+            int num_fields = mysql_num_fields(result);
+
+            if ( (num_rows != 1) ) {
+                stringstream tmp;
+                tmp << "Search: DB returned " << num_rows << " leases for address "
+                    << hex << x << dec;
+                failure(tmp.str().c_str());
+            }
+
+            MYSQL_ROW row = mysql_fetch_row(result);
+            // pretend to do something with it
+
+            printf("lease_id=%s addr=%s valid_lft=%s cltt=%s\n",
+                   (row[0]?row[0]:"NULL"),
+                   (row[1]?row[1]:"NULL"),
+                   (row[4]?row[4]:"NULL"),
+                   (row[5]?row[5]:"NULL"));
+
+            mysql_free_result(result);
+        }
+        printf(".");
+    }
+
+    printf("\n");
 }
 
 void MySQL_uBenchmark::printInfo() {
@@ -316,7 +406,7 @@ int main(int argc, const char * argv[]) {
 
     const char * hostname ="localhost";
     const char * user = "root";
-    const char * passwd = "foobletch";
+    const char * passwd = "secret";
     const char * dbname = "kea";
     uint32_t num = 100;
 



More information about the bind10-changes mailing list