]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
fixed benchmarks
authorRazvan Becheriu <ravan@isc.org>
Tue, 5 Mar 2019 16:06:52 +0000 (18:06 +0200)
committerTomek Mrugalski <tomek@isc.org>
Fri, 19 Apr 2019 07:55:02 +0000 (03:55 -0400)
14 files changed:
src/lib/dhcpsrv/benchmarks/Makefile.am
src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h
src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h
src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/parameters.h
src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/run_benchmarks.cc

index c99b884fac97ad3359337559e59de43658dba45e..14c52a5c2b1198161109c72fa388b5d8977c3162 100644 (file)
@@ -70,15 +70,28 @@ if HAVE_CQL
 run_benchmarks_LDFLAGS += $(CQL_LIBS)
 endif
 
-run_benchmarks_LDADD  = $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+run_benchmarks_LDADD  = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
 run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
 run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
 run_benchmarks_LDADD += $(BENCHMARK_LDADD)
 run_benchmarks_LDADD += $(LOG4CPLUS_LIBS)
 run_benchmarks_LDADD += $(CRYPTO_LIBS)
 run_benchmarks_LDADD += $(BOOST_LIBS)
 run_benchmarks_LDADD += $(GTEST_LDADD)
+
+if HAVE_MYSQL
+run_benchmarks_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
+endif
+
+if HAVE_PGSQL
+run_benchmarks_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
+endif
+
+if HAVE_CQL
+run_benchmarks_LDADD += $(top_builddir)/src/lib/cql/testutils/libcqltest.la
+endif
+
 endif
 
 noinst_PROGRAMS = $(BENCHMARKS)
index 3e25aa3b170b3945bd8d3d065c301887c3b667c3..5cdbc0d1f8c49080f5eb0c4fba794193be6d8405 100644 (file)
 
 #include <config.h>
 
+#include <cql/testutils/cql_schema.h>
+
 #include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/cql_schema.h>
+#include <dhcpsrv/host_mgr.h>
+
 #include <iostream>
 
-using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
+using namespace isc::db::test;
 using namespace isc::dhcp;
+using namespace isc::dhcp::bench;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking Cassandra host backend
-class CqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
-public:
-
+struct CqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates HostMgr
@@ -41,13 +42,18 @@ public:
         // Ensure we have the proper schema with no transient data.
         createCqlSchema();
         try {
-            HostDataSourceFactory::destroy();
-            HostDataSourceFactory::create(validCqlConnectionString());
+            HostMgr::delBackend("cql");
+            HostMgr::addBackend(validCqlConnectionString());
         } catch (...) {
             cerr << "ERROR: unable to open database" << endl;
             throw;
         }
-        hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
+        hdsptr_ = HostMgr::instance().getHostDataSource();
+    }
+
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
     }
 
     /// @brief Cleans up after the test.
@@ -59,10 +65,15 @@ public:
                     " is opened in read-only mode, continuing..."
                  << endl;
         }
-        HostDataSourceFactory::destroy();
+        HostMgr::delBackend("cql");
         // If data wipe enabled, delete transient data otherwise destroy the schema
         destroyCqlSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
 };
 
 /// Defines steps necessary for conducting a benchmark that measures
@@ -85,16 +96,6 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, updateHosts)(benchmark::State& st
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGetAllByHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll)(benchmark::State& state) {
@@ -115,16 +116,6 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& s
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet4BySubnetHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) {
@@ -145,16 +136,6 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::S
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet6SubnetIdDuidHWAddr();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) {
@@ -188,61 +169,55 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& sta
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts insertion.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, insertHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts update.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, updateHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll(v4-reservation) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllv4Resv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(subnet-id, v4-reservation) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, ip-address) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(ip-prefix, prefix-len) call.
 BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6Prefix)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index 4fa64ecd4f7685a22ad981a25950461ae5ff2ec5..934605f8333cc6d2d4884f26f4d79471399ad23d 100644 (file)
 
 #include <config.h>
 
+#include <cql/testutils/cql_schema.h>
+
 #include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/testutils/cql_schema.h>
 
+using namespace isc::db::test;
 using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
 using namespace isc::dhcp;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking Cassandra lease backend
-class CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
-public:
+struct CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates LeaseMgr
@@ -48,6 +48,11 @@ public:
         lmptr_ = &(LeaseMgrFactory::instance());
     }
 
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
+    }
+
     /// @brief Cleans up after the test.
     void TearDown(::benchmark::State const&) override {
         try {
@@ -61,6 +66,13 @@ public:
         // If data wipe enabled, delete transient data otherwise destroy the schema
         destroyCqlSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
+
+
 };
 
 // Defines a benchmark that measures IPv4 leases insertion.
@@ -176,7 +188,7 @@ BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::St
 // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid
 // and subnet-id.
 BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-                  (benchmark::State& state) {
+(benchmark::State& state) {
     const size_t lease_count = state.range(0);
     while (state.KeepRunning()) {
         setUpWithInserts6(state, lease_count);
@@ -193,66 +205,79 @@ BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& st
     }
 }
 
-
 /// The following macros define run parameters for previously defined
 /// Cassandra benchmarks.
 
 /// A benchmark that measures IPv4 leases insertion.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 leases update.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by IP address.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address and a
 /// subnet-id.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id and subnet-id.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv4 leases retrieval.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases insertion.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases update.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type and IP address.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid and iaid.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid, iaid and
 /// subnet-id.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv6 leases retrieval.
 BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index ed944b0871388ecff34745b01765262b182d3d5a..00e9e0af415c29f52d3da7a5379f45b0135f51a9 100644 (file)
 
 #include <config.h>
 
-#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
-
 #include <asiolink/io_address.h>
+
+#include <database/testutils/schema.h>
+
 #include <dhcp/dhcp6.h>
 #include <dhcp/libdhcp++.h>
 #include <dhcp/option4_addrlst.h>
@@ -27,8 +28,9 @@
 #include <dhcp/option_int.h>
 #include <dhcp/option_string.h>
 #include <dhcp/option_vendor.h>
+
+#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
 #include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/schema.h>
 #include <dhcpsrv/testutils/host_data_source_utils.h>
 
 using isc::asiolink::IOAddress;
@@ -40,8 +42,7 @@ namespace isc {
 namespace dhcp {
 namespace bench {
 
-GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark()
-    : hdsptr_() {
+GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark() : hdsptr_() {
     LibDHCP::clearRuntimeOptionDefs();
 }
 
@@ -51,8 +52,7 @@ GenericHostDataSourceBenchmark::~GenericHostDataSourceBenchmark() {
 }
 
 void
-GenericHostDataSourceBenchmark::setUp(::benchmark::State& state,
-                                      size_t const& host_count) {
+GenericHostDataSourceBenchmark::setUp(::benchmark::State& state, size_t const& host_count) {
     state.PauseTiming();
     SetUp(state);
     prepareHosts(host_count);
@@ -97,7 +97,8 @@ GenericHostDataSourceBenchmark::createVendorOption(const Option::Universe& unive
 }
 
 void
-GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool formatted,
+GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host,
+                                               const bool formatted,
                                                const AddedOptions& added_options) const {
     OptionDefSpaceContainer defs;
 
@@ -105,22 +106,26 @@ GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool f
         // Add DHCPv4 options.
         CfgOptionPtr opts = host->getCfgOption4();
         opts->add(createOption<OptionString>(Option::V4, DHO_BOOT_FILE_NAME, true, formatted,
-                                             "my-boot-file"), DHCP4_OPTION_SPACE);
-        opts->add(createOption<OptionUint8>(Option::V4, DHO_DEFAULT_IP_TTL,
-                                            false, formatted, 64), DHCP4_OPTION_SPACE);
+                                             "my-boot-file"),
+                  DHCP4_OPTION_SPACE);
+        opts->add(createOption<OptionUint8>(Option::V4, DHO_DEFAULT_IP_TTL, false, formatted, 64),
+                  DHCP4_OPTION_SPACE);
         opts->add(createOption<OptionUint32>(Option::V4, 1, false, formatted, 312131),
                   "vendor-encapsulated-options");
         opts->add(createAddressOption<Option4AddrLst>(254, false, formatted, "192.0.2.3"),
                   DHCP4_OPTION_SPACE);
         opts->add(createEmptyOption(Option::V4, 1, true), "isc");
-        opts->add(createAddressOption<Option4AddrLst>(2, false, formatted, "10.0.0.5",
-                                                      "10.0.0.3", "10.0.3.4"), "isc");
+        opts->add(createAddressOption<Option4AddrLst>(2, false, formatted, "10.0.0.5", "10.0.0.3",
+                                                      "10.0.3.4"),
+                  "isc");
 
         // Add definitions for DHCPv4 non-standard options.
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", 1,
-                                         "uint32")), "vendor-encapsulated-options");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-254", 254, "ipv4-address",
-                                         true)), DHCP4_OPTION_SPACE);
+        defs.addItem(
+            OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", 1, "uint32")),
+            "vendor-encapsulated-options");
+        defs.addItem(
+            OptionDefinitionPtr(new OptionDefinition("option-254", 254, "ipv4-address", true)),
+            DHCP4_OPTION_SPACE);
         defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "empty")), "isc");
         defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "ipv4-address", true)),
                      "isc");
@@ -129,23 +134,27 @@ GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool f
     if ((added_options == DHCP6_ONLY) || (added_options == DHCP4_AND_DHCP6)) {
         // Add DHCPv6 options.
         CfgOptionPtr opts = host->getCfgOption6();
-        opts->add(createOption<OptionString>(Option::V6, D6O_BOOTFILE_URL, true,
-                                             formatted, "my-boot-file"), DHCP6_OPTION_SPACE);
-        opts->add(createOption<OptionUint32>(Option::V6, D6O_INFORMATION_REFRESH_TIME,
-                                             false, formatted, 3600), DHCP6_OPTION_SPACE);
+        opts->add(createOption<OptionString>(Option::V6, D6O_BOOTFILE_URL, true, formatted,
+                                             "my-boot-file"),
+                  DHCP6_OPTION_SPACE);
+        opts->add(createOption<OptionUint32>(Option::V6, D6O_INFORMATION_REFRESH_TIME, false,
+                                             formatted, 3600),
+                  DHCP6_OPTION_SPACE);
         opts->add(createVendorOption(Option::V6, false, formatted, 2495), DHCP6_OPTION_SPACE);
         opts->add(createAddressOption<Option6AddrLst>(1024, false, formatted, "2001:db8:1::1"),
                   DHCP6_OPTION_SPACE);
         opts->add(createEmptyOption(Option::V6, 1, true), "isc2");
         opts->add(createAddressOption<Option6AddrLst>(2, false, formatted, "3000::1", "3000::2",
-                                                      "3000::3"), "isc2");
+                                                      "3000::3"),
+                  "isc2");
 
         // Add definitions for DHCPv6 non-standard options.
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1024", 1024, "ipv6-address",
-                                                              true)), DHCP6_OPTION_SPACE);
+        defs.addItem(
+            OptionDefinitionPtr(new OptionDefinition("option-1024", 1024, "ipv6-address", true)),
+            DHCP6_OPTION_SPACE);
         defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "empty")), "isc2");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address",
-                                                              true)), "isc2");
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address", true)),
+                     "isc2");
     }
 
     // Register created "runtime" option definitions. They will be used by a
@@ -189,14 +198,6 @@ GenericHostDataSourceBenchmark::updateHosts() {
     }
 }
 
-void
-GenericHostDataSourceBenchmark::benchGetAllByHWAddrDuid() {
-    for (HostPtr host : hosts_) {
-        ConstHostCollection from_hds =
-            hdsptr_->getAll(host->getHWAddress(), host->getDuid());
-    }
-}
-
 void
 GenericHostDataSourceBenchmark::benchGetAll() {
     for (HostPtr host : hosts_) {
@@ -212,21 +213,12 @@ GenericHostDataSourceBenchmark::getAllv4Resv() {
     }
 }
 
-void
-GenericHostDataSourceBenchmark::benchGet4BySubnetHWAddrDuid() {
-    for (HostPtr host : hosts_) {
-        std::vector<uint8_t> hwaddr = host->getIdentifier();
-        hdsptr_->get4(host->getIPv4SubnetID(), HWAddrPtr(new HWAddr(hwaddr,
-                          host->getIdentifierType())), host->getDuid());
-    }
-}
-
 void
 GenericHostDataSourceBenchmark::benchGet4IdentifierSubnetId() {
     for (HostPtr host : hosts_) {
         std::vector<uint8_t> hwaddr = host->getIdentifier();
-        hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(),
-                      &hwaddr[0], hwaddr.size());
+        hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(), &hwaddr[0],
+                      hwaddr.size());
     }
 }
 
@@ -237,20 +229,12 @@ GenericHostDataSourceBenchmark::benchGet4SubnetIdv4Resrv() {
     }
 }
 
-void
-GenericHostDataSourceBenchmark::benchGet6SubnetIdDuidHWAddr() {
-    for (HostPtr host : hosts_) {
-        hdsptr_->get6(host->getIPv6SubnetID(), host->getDuid(),
-                      host->getHWAddress());
-    }
-}
-
 void
 GenericHostDataSourceBenchmark::benchGet6IdentifierSubnetId() {
     for (HostPtr host : hosts_) {
         std::vector<uint8_t> hwaddr = host->getIdentifier();
-        hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(),
-                      &hwaddr[0], hwaddr.size());
+        hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(), &hwaddr[0],
+                      hwaddr.size());
     }
 }
 
@@ -266,8 +250,7 @@ void
 GenericHostDataSourceBenchmark::benchGet6Prefix() {
     for (HostPtr host : hosts_) {
         const IPv6ResrvRange range = host->getIPv6Reservations();
-        hdsptr_->get6(range.first->second.getPrefix(),
-                      range.first->second.getPrefixLen());
+        hdsptr_->get6(range.first->second.getPrefix(), range.first->second.getPrefixLen());
     }
 }
 
index 8521bcb09ea227e95c3471643537806dbec53cdd..d445e55a2743d48d8cbb33eba3a1216e996ad5e2 100644 (file)
@@ -28,16 +28,14 @@ namespace dhcp {
 namespace bench {
 
 /// @brief Base fixture class for benchmarking host backends.
-class GenericHostDataSourceBenchmark : public ::benchmark::Fixture {
-public:
-
+struct GenericHostDataSourceBenchmark : public ::benchmark::Fixture {
     /// @brief Defines universe (IPv4 or IPv6)
     enum Universe { V4, V6 };
 
     /// @brief Defines what kind of options should be added for a host
     enum AddedOptions {
-        DHCP4_ONLY,      ///< DHCPv4-only options
-        DHCP6_ONLY,      ///< DHCPv6-only options
+        DHCP4_ONLY,  ///< DHCPv4-only options
+        DHCP6_ONLY,  ///< DHCPv6-only options
         DHCP4_AND_DHCP6  ///< Both DHCPv4 and DHCPv6 options
     };
 
@@ -99,11 +97,12 @@ public:
     /// @param address3 third address to be used (optional)
     /// @return the option created wrapped in an option descriptor structure
     template <typename OptionType>
-    OptionDescriptor
-    createAddressOption(const uint16_t option_type, const bool persist,
-                        const bool formatted, const std::string& address1 = "",
-                        const std::string& address2 = "",
-                        const std::string& address3 = "") const {
+    OptionDescriptor createAddressOption(const uint16_t option_type,
+                                         const bool persist,
+                                         const bool formatted,
+                                         const std::string& address1 = "",
+                                         const std::string& address2 = "",
+                                         const std::string& address3 = "") const {
 
         std::ostringstream s;
         // First address.
@@ -158,7 +157,8 @@ public:
     /// @param host host reservation to be extended with options
     /// @param formatted whether to generate text representation
     /// @param added_options v4, v6 or both
-    void addTestOptions(const HostPtr& host,const bool formatted,
+    void addTestOptions(const HostPtr& host,
+                        const bool formatted,
                         const AddedOptions& added_options) const;
 
     /// @brief Sets up timers, creates and inserts hosts.
@@ -184,8 +184,6 @@ public:
     /// @brief Updates all hosts stored in hosts_ in the benchmarked host backend
     void updateHosts();
 
-    void benchGetAllByHWAddrDuid();
-
     /// @brief Essential steps required to benchmark the
     ///        getAll(identifier-type, identifier) call.
     void benchGetAll();
@@ -194,10 +192,6 @@ public:
     ///        using getAll(ipv4-reservation) call.
     void getAllv4Resv();
 
-    /// @brief Essential steps requires to benchmark host reservation retrieval
-    ///        using getAll(hw-addr, duid) call.
-    void benchGet4BySubnetHWAddrDuid();
-
     /// @brief Essential steps requires to benchmark host reservation retrieval
     ///        using getAll(identifier-type, identifier, subnet-id) call.
     void benchGet4IdentifierSubnetId();
@@ -206,10 +200,6 @@ public:
     ///        using getAll(v4-reservation) call.
     void benchGet4SubnetIdv4Resrv();
 
-    /// @brief Essential steps requires to benchmark host reservation retrieval
-    ///        using get6(subnet-id, duid, hw-addr) call.
-    void benchGet6SubnetIdDuidHWAddr();
-
     /// @brief Essential steps requires to benchmark host reservation retrieval
     ///        using get6(identifier-type, identifier, subnet-id) call.
     void benchGet6IdentifierSubnetId();
index 19160a2b8256f03a088c01aaa171921a1630f77b..7cb0bf0b3af2f0ea69aab3c376e536a748575035 100644 (file)
@@ -18,9 +18,7 @@
 #include <config.h>
 
 #include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
-
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/testutils/cql_schema.h>
 
 #include <chrono>
 #include <iomanip>
@@ -29,7 +27,6 @@
 #include <vector>
 
 using namespace isc::asiolink;
-using namespace isc::dhcp::test;
 using namespace std;
 using namespace std::chrono;
 
@@ -37,8 +34,7 @@ namespace isc {
 namespace dhcp {
 namespace bench {
 
-GenericLeaseMgrBenchmark::GenericLeaseMgrBenchmark()
-    : lmptr_(NULL) {
+GenericLeaseMgrBenchmark::GenericLeaseMgrBenchmark() : lmptr_(NULL) {
 }
 
 GenericLeaseMgrBenchmark::~GenericLeaseMgrBenchmark() {
@@ -217,8 +213,7 @@ GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid() {
 void
 GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid_subnetid() {
     for (Lease6Ptr const& lease : leases6_) {
-        lmptr_->getLease6(lease->type_, *lease->duid_, lease->iaid_,
-                          lease->subnet_id_);
+        lmptr_->getLease6(lease->type_, *lease->duid_, lease->iaid_, lease->subnet_id_);
     }
 }
 
index eb4de3926e3e0a363a1a7f2e9a107d2e40b69ef8..d636e28cca74da8120f7cb9182039675119bbe0c 100644 (file)
@@ -27,9 +27,7 @@ namespace dhcp {
 namespace bench {
 
 /// @brief A base class for a fixture for specific lease manager benchmarks
-class GenericLeaseMgrBenchmark : public benchmark::Fixture {
-public:
-
+struct GenericLeaseMgrBenchmark : public benchmark::Fixture {
     /// Specifies the IP protocol family to be bested.
     enum Universe { V4, V6 };
 
index ce6e738af59257158a2fedfbbeb8d873e77c7dc9..2afe5f4205adeee5b100fed851e9aaabe5dd880f 100644 (file)
@@ -8,8 +8,8 @@
 
 #include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/memfile_lease_mgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
+#include <dhcpsrv/memfile_lease_mgr.h>
 #include <dhcpsrv/testutils/lease_file_io.h>
 
 using namespace isc::dhcp::bench;
@@ -20,14 +20,11 @@ using namespace std;
 namespace {
 
 /// @brief This is a fixture class used for benchmarking Memfile lease backend
-class MemfileLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
-public:
-
+struct MemfileLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
     /// @brief Constructor
     ///
     /// Sets the files used for writing lease files.
-    MemfileLeaseMgrBenchmark()
-        : io4_(""), io6_("") {
+    MemfileLeaseMgrBenchmark() : io4_(""), io6_("") {
     }
 
     /// @brief Setup routine.
@@ -54,6 +51,11 @@ public:
         lmptr_ = &(LeaseMgrFactory::instance());
     }
 
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
+    }
+
     /// @brief Creates instance of the backend.
     ///
     /// @param u Universe (v4 or V6).
@@ -62,7 +64,7 @@ public:
             LeaseMgrFactory::create(getConfigString(u));
         } catch (...) {
             std::cerr << "*** ERROR: unable to create instance of the Memfile\n"
-                " lease database backend.\n";
+                         " lease database backend.\n";
             throw;
         }
         lmptr_ = &(LeaseMgrFactory::instance());
@@ -80,8 +82,8 @@ public:
     /// @return Configuration string for @c LeaseMgrFactory.
     static std::string getConfigString(Universe u) {
         std::ostringstream s;
-        s << "type=memfile " << (u == V4 ? "universe=4 " : "universe=6 ") << "name="
-          << getLeaseFilePath(u == V4 ? "leasefile4_0.csv" : "leasefile6_0.csv")
+        s << "type=memfile " << (u == V4 ? "universe=4 " : "universe=6 ")
+          << "name=" << getLeaseFilePath(u == V4 ? "leasefile4_0.csv" : "leasefile6_0.csv")
           << " lfc-interval=0";
         return (s.str());
     }
@@ -125,7 +127,8 @@ public:
             lmptr_->rollback();
         } catch (...) {
             std::cerr << "WARNING: rollback has failed. This is surprising as "
-                "memfile doesn't support rollback." << std::endl;
+                         "memfile doesn't support rollback."
+                      << std::endl;
         }
 
         LeaseMgrFactory::destroy();
@@ -135,6 +138,11 @@ public:
         removeFiles(getLeaseFilePath("leasefile6_0.csv"));
     }
 
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
+
     /// @brief Object providing access to v4 lease IO.
     LeaseFileIO io4_;
 
@@ -255,7 +263,7 @@ BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark
 // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid
 // and subnet-id.
 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-                  (benchmark::State& state) {
+(benchmark::State& state) {
     const size_t lease_count = state.range(0);
     while (state.KeepRunning()) {
         setUpWithInserts6(state, lease_count);
@@ -272,66 +280,79 @@ BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State
     }
 }
 
-
 /// The following macros define run parameters for previously defined
 /// memfile benchmarks.
 
 /// A benchmark that measures IPv4 leases insertion.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, insertLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 leases update.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by IP address.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address and a
 /// subnet-id.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_clientid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id and subnet-id.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_clientid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv4 leases retrieval.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getExpiredLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases insertion.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, insertLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases update.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type and IP address.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid and iaid.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid, iaid and
 /// subnet-id.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv6 leases retrieval.
 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index 3b93a66614d1f2ddd6c5690f59dceb25c39e5f0b..97c7652dab542c8cf6372db42fa08e91f0c1ae1b 100644 (file)
 
 #include <config.h>
 
+#include <mysql/testutils/mysql_schema.h>
+
 #include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/mysql_schema.h>
+#include <dhcpsrv/host_mgr.h>
+
 #include <iostream>
 
-using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
+using namespace isc::db::test;
 using namespace isc::dhcp;
+using namespace isc::dhcp::bench;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking MySQL host backend
-class MySqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
-public:
-
+struct MySqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates HostMgr
@@ -41,13 +42,18 @@ public:
         // Ensure we have the proper schema with no transient data.
         createMySQLSchema();
         try {
-            HostDataSourceFactory::destroy();
-            HostDataSourceFactory::create(validMySQLConnectionString());
+            HostMgr::delBackend("mysql");
+            HostMgr::addBackend(validMySQLConnectionString());
         } catch (...) {
             cerr << "ERROR: unable to open database" << endl;
             throw;
         }
-        hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
+        hdsptr_ = HostMgr::instance().getHostDataSource();
+    }
+
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
     }
 
     /// @brief Cleans up after the test.
@@ -59,10 +65,15 @@ public:
                     " is opened in read-only mode, continuing..."
                  << endl;
         }
-        HostDataSourceFactory::destroy();
+        HostMgr::delBackend("mysql");
         // If data wipe enabled, delete transient data otherwise destroy the schema.
         destroyMySQLSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
 };
 
 /// Defines steps necessary for conducting a benchmark that measures
@@ -85,16 +96,6 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, updateHosts)(benchmark::State&
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGetAllByHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAll)(benchmark::State& state) {
@@ -115,16 +116,6 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State&
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet4BySubnetHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) {
@@ -145,16 +136,6 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark:
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet6SubnetIdDuidHWAddr();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) {
@@ -188,61 +169,55 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts insertion.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, insertHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts update.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, updateHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAll)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll(v4-reservation) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllv4Resv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(subnet-id, v4-reservation) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, ip-address) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(ip-prefix, prefix-len) call.
 BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6Prefix)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index 9353557bce7cbda2f7defd6a36a037d809df543f..7d59ad4558c4c5c6dd9d4dad5fbe203c965182d1 100644 (file)
 #include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/testutils/mysql_schema.h>
 
-using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
+#include <mysql/testutils/mysql_schema.h>
+
+using namespace isc::db::test;
 using namespace isc::dhcp;
+using namespace isc::dhcp::bench;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking MySQL lease backend
-class MySqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
-public:
+struct MySqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates LeaseMgr
@@ -48,6 +48,11 @@ public:
         lmptr_ = &(LeaseMgrFactory::instance());
     }
 
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
+    }
+
     /// @brief Cleans up after the test.
     void TearDown(::benchmark::State const&) override {
         try {
@@ -61,6 +66,11 @@ public:
         // If data wipe enabled, delete transient data otherwise destroy the schema.
         destroyMySQLSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
 };
 
 // Defines a benchmark that measures IPv4 leases insertion.
@@ -176,7 +186,7 @@ BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::
 // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid
 // and subnet-id.
 BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-                  (benchmark::State& state) {
+(benchmark::State& state) {
     const size_t lease_count = state.range(0);
     while (state.KeepRunning()) {
         setUpWithInserts6(state, lease_count);
@@ -193,66 +203,79 @@ BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State&
     }
 }
 
-
 /// The following macros define run parameters for previously defined
 /// MySQL benchmarks.
 
 /// A benchmark that measures IPv4 leases insertion.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, insertLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 leases update.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, updateLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by IP address.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease4_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease4_hwaddr)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address and a
 /// subnet-id.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease4_clientid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id and subnet-id.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease4_clientid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv4 leases retrieval.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getExpiredLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases insertion.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, insertLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases update.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, updateLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type and IP address.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease6_type_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid and iaid.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid, iaid and
 /// subnet-id.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv6 leases retrieval.
 BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getExpiredLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index 2de54f93ce3059770e91f0a0b972097b92b7fde3..2f54c28351228672f3151067269d52603e57504f 100644 (file)
@@ -26,7 +26,7 @@ constexpr size_t MIN_LEASE_COUNT = 512;
 /// @brief A maximum number of leases used in a benchmark
 constexpr size_t MAX_LEASE_COUNT = 0xfffd;
 
- /// @brief A minimum number of leases used in a benchmark
+/// @brief A minimum number of leases used in a benchmark
 constexpr size_t MIN_HOST_COUNT = 512;
 /// @brief A maximum number of leases used in a benchmark
 constexpr size_t MAX_HOST_COUNT = 0xfffd;
@@ -36,8 +36,8 @@ constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
 
 /// @}
 
-}
-}
-}
+}  // namespace bench
+}  // namespace dhcp
+}  // namespace isc
 
 #endif
index c57aa1e6a66e15d78b7f81dd1277f6fe1e4b49da..ef3d6b7f4dfb42de0a77f3849c4e7609851be6b0 100644 (file)
 #include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/pgsql_schema.h>
+#include <dhcpsrv/host_mgr.h>
+
+#include <pgsql/testutils/pgsql_schema.h>
+
 #include <iostream>
 
+using namespace isc::db::test;
 using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
 using namespace isc::dhcp;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking PostgreSQL host backend
-class PgSqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
-public:
-
+struct PgSqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates HostMgr
@@ -41,13 +42,18 @@ public:
         // Ensure we have the proper schema with no transient data.
         createPgSQLSchema();
         try {
-            HostDataSourceFactory::destroy();
-            HostDataSourceFactory::create(validPgSQLConnectionString());
+            HostMgr::delBackend("postgresql");
+            HostMgr::addBackend(validPgSQLConnectionString());
         } catch (...) {
             cerr << "ERROR: unable to open database" << endl;
             throw;
         }
-        hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
+        hdsptr_ = HostMgr::instance().getHostDataSource();
+    }
+
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
     }
 
     /// @brief Cleans up after the test.
@@ -59,10 +65,15 @@ public:
                     " is opened in read-only mode, continuing..."
                  << endl;
         }
-        HostDataSourceFactory::destroy();
+        HostMgr::delBackend("postgresql");
         // If data wipe enabled, delete transient data otherwise destroy the schema
         destroyPgSQLSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
 };
 
 /// Defines steps necessary for conducting a benchmark that measures
@@ -85,16 +96,6 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, updateHosts)(benchmark::State&
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGetAllByHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAll)(benchmark::State& state) {
@@ -115,16 +116,6 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State&
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet4BySubnetHWAddrDuid();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) {
@@ -145,16 +136,6 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark:
     }
 }
 
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) {
-    const size_t host_count = state.range(0);
-    while (state.KeepRunning()) {
-        setUpWithInserts(state, host_count);
-        benchGet6SubnetIdDuidHWAddr();
-    }
-}
-
 /// Defines steps necessary for conducting a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) {
@@ -188,61 +169,55 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts insertion.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts update.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, updateHosts)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll(hw-addr, duid) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll4(hw-addr, duid) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by getAll(v4-reservation) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(subnet-id, hw-addr, duid) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get4(subnet-id, v4-reservation) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, duid, hw-addr) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(subnet-id, ip-address) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 /// Defines parameters necessary for running a benchmark that measures
 /// hosts retrieval by get6(ip-prefix, prefix-len) call.
 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix)
-    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+    ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index 05f2429bd219ae90efa62005b657fa675e385067..f9d0c89807ae8069d3fb7932af6dd45062435f90 100644 (file)
 #include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
 #include <dhcpsrv/benchmarks/parameters.h>
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/testutils/pgsql_schema.h>
 
-using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
+#include <pgsql/testutils/pgsql_schema.h>
+
+using namespace isc::db::test;
 using namespace isc::dhcp;
+using namespace isc::dhcp::bench;
 using namespace std;
 
 namespace {
 
 /// @brief This is a fixture class used for benchmarking PostgreSQL lease backend
-class PgSqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
-public:
+struct PgSqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
     /// @brief Setup routine.
     ///
     /// It cleans up schema and recreates tables, then instantiates LeaseMgr
@@ -48,6 +48,11 @@ public:
         lmptr_ = &(LeaseMgrFactory::instance());
     }
 
+    void SetUp(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        SetUp(cs);
+    }
+
     /// @brief Cleans up after the test.
     void TearDown(::benchmark::State const&) override {
         try {
@@ -61,6 +66,11 @@ public:
         // If data wipe enabled, delete transient data otherwise destroy the schema
         destroyPgSQLSchema();
     }
+
+    void TearDown(::benchmark::State& s) override {
+        ::benchmark::State const& cs = s;
+        TearDown(cs);
+    }
 };
 
 // Defines a benchmark that measures IPv4 leases insertion.
@@ -176,7 +186,7 @@ BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::
 // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid
 // and subnet-id.
 BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-                  (benchmark::State& state) {
+(benchmark::State& state) {
     const size_t lease_count = state.range(0);
     while (state.KeepRunning()) {
         setUpWithInserts6(state, lease_count);
@@ -193,66 +203,79 @@ BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State&
     }
 }
 
-
 /// The following macros define run parameters for previously defined
 /// PostgreSQL benchmarks.
 
 /// A benchmark that measures IPv4 leases insertion.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, insertLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 leases update.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, updateLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by IP address.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease4_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease4_hwaddr)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by hardware address and a
 /// subnet-id.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease4_clientid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv4 lease retrieval by client-id and subnet-id.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease4_clientid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv4 leases retrieval.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getExpiredLeases4)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases insertion.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, insertLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 leases update.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, updateLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type and IP address.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease6_type_address)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid and iaid.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease6_type_duid_iaid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures IPv6 lease retrieval by lease type, duid, iaid and
 /// subnet-id.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 /// A benchmark that measures expired IPv6 leases retrieval.
 BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getExpiredLeases6)
-    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
+    ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)
+    ->Unit(UNIT);
 
 }  // namespace
index bcc4a536a900913bf4f2aad9041ed279b000d365..35ac2c33b37e9878e1d18bd2e5c6e4bf5d842723 100644 (file)
@@ -20,8 +20,7 @@
 #include <log/logger_support.h>
 
 /// @brief A simple class that initializes logging.
-class Initializer {
-public:
+struct Initializer {
     Initializer() {
         isc::log::initLogger();
     }
@@ -29,5 +28,4 @@ public:
 
 Initializer initializer;
 
-BENCHMARK_MAIN()
-
+BENCHMARK_MAIN();