]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[github36] Another bunch of changes after review:
authorTomek Mrugalski <tomasz@isc.org>
Tue, 13 Feb 2018 18:56:27 +0000 (18:56 +0000)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 13 Feb 2018 18:56:27 +0000 (18:56 +0000)
 - using namespace cleaned up
 - all host benchmarks are now commented
 - common parameters moved to parameters.h
 - code wrapping fixed

12 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.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 [new file with mode: 0644]
src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc

index 005452e231d4878aefa6f5cc046f853c07d4fbed..7f2f05c6cb06196207eb1397a1830bb4823f56d2 100644 (file)
@@ -23,6 +23,7 @@ run_benchmarks_SOURCES  = run_benchmarks.cc
 run_benchmarks_SOURCES += generic_lease_mgr_benchmark.cc generic_lease_mgr_benchmark.h
 run_benchmarks_SOURCES += generic_host_data_source_benchmark.cc generic_host_data_source_benchmark.h
 run_benchmarks_SOURCES += memfile_lease_mgr_benchmark.cc
+run_benchmarks_SOURCES += parameters.h
 
 if HAVE_MYSQL
 run_benchmarks_SOURCES += mysql_lease_mgr_benchmark.cc
index 6973a86e26c85575a7c87f475ec389fc3bcd3b08..ad3dd6286a0466ab1b455c9bbe78a873a309145b 100644 (file)
 #include <config.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 <iostream>
 
-using isc::dhcp::bench::GenericHostDataSourceBenchmark;
-using isc::dhcp::test::createCqlSchema;
-using isc::dhcp::test::destroyCqlSchema;
-using isc::dhcp::HostDataSourceFactory;
-using isc::dhcp::test::validCqlConnectionString;
-using std::cerr;
-using std::endl;
+using namespace isc::dhcp::bench;
+using namespace isc::dhcp::test;
+using namespace isc::dhcp;
+using namespace std;
 
 namespace {
 
@@ -164,21 +162,64 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& sta
     }
 }
 
-constexpr size_t MIN_HOST_COUNT = 512;
-constexpr size_t MAX_HOST_COUNT = 0xfffd;
-constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
-
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
 
 }  // namespace
index eed7ed05837f1b5c49926fe0c56608dd071f3823..5f21cd85913476c73f56fd1d65f03e5432d942d2 100644 (file)
@@ -18,6 +18,7 @@
 #include <config.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>
 
index 83d26762306e7265a02759cb49788835ee6ba0fd..ed944b0871388ecff34745b01765262b182d3d5a 100644 (file)
@@ -130,32 +130,22 @@ GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool f
         // 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(createVendorOption(Option::V6, false, formatted, 2495),
-                  DHCP6_OPTION_SPACE);
-        opts->add(createAddressOption<Option6AddrLst>(1024, false, formatted,
-                                                      "2001:db8:1::1"),
+                                             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");
+        opts->add(createAddressOption<Option6AddrLst>(2, false, formatted, "3000::1", "3000::2",
+                                                      "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-1", 1, "empty")),
-            "isc2");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "option-2", 2, "ipv6-address", true)),
-                     "isc2");
+        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");
     }
 
     // Register created "runtime" option definitions. They will be used by a
@@ -226,9 +216,8 @@ 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());
+        hdsptr_->get4(host->getIPv4SubnetID(), HWAddrPtr(new HWAddr(hwaddr,
+                          host->getIdentifierType())), host->getDuid());
     }
 }
 
index e4e98f27acfd18c7422718164ad847229dc03722..dd1b7ecb96f6a336e599630aa1927b84a5063988 100644 (file)
@@ -27,7 +27,7 @@ namespace isc {
 namespace dhcp {
 namespace bench {
 
-    /// @brief Base fixture class for benchmarking host bakcends.
+/// @brief Base fixture class for benchmarking host bakcends.
 class GenericHostDataSourceBenchmark : public ::benchmark::Fixture {
 public:
 
@@ -188,22 +188,36 @@ public:
     ///        getAll(identifier-type, identifier) call.
     void benchGetAll();
 
-    /// @brief Essential stpes requires to benchmark host reservation retrieval
+    /// @brief Essential steps required to benchmark host reservation retrieval
     ///        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();
 
+    /// @brief Essential steps requires to benchmark host reservation retrieval
+    ///        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();
 
+    /// @brief Essential steps requires to benchmark host reservation retrieval
+    ///        using get6(ip-addr, subnet-id) call.
     void benchGet6SubnetIdAddr();
 
+    /// @brief Essential steps requires to benchmark host reservation retrieval
+    ///        using get6(prefix, len) call.
     void benchGet6Prefix();
 
     /// Pointer to the host backend being benchmarked
index 5b3356260d95069be0c4a6435e7a21027d403884..eb4de3926e3e0a363a1a7f2e9a107d2e40b69ef8 100644 (file)
@@ -26,23 +26,6 @@ namespace isc {
 namespace dhcp {
 namespace bench {
 
-/// @defgroup memfile_params Benchmark parameters that define boundary values
-///           for benchmarks.
-///
-/// The range is defined as 512..65533. Google benchmark will pick a few specifc
-/// values: 512, 4096, 32768, 65533.
-
-/// @{
-
-/// @brief A minimum number of leases used in a benchmark
-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 time unit used - all results to be expressed in us (microseconds)
-constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
-
-/// @}
-
 /// @brief A base class for a fixture for specific lease manager benchmarks
 class GenericLeaseMgrBenchmark : public benchmark::Fixture {
 public:
index 8d61a10742f66b90127ae39e10bfd5e107e7cdcc..11b06555107a32239bb1515ed7215e0901160027 100644 (file)
@@ -7,6 +7,7 @@
 #include <config.h>
 
 #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/testutils/lease_file_io.h>
@@ -14,8 +15,6 @@
 using namespace isc::dhcp;
 using namespace isc::dhcp::test;
 using namespace isc::dhcp::bench;
-using isc::dhcp::LeaseMgrFactory;
-using isc::dhcp::bench::GenericLeaseMgrBenchmark;
 
 namespace {
 
index d26704926c64f1794b65ab423927d834319b63f0..4eb39ce621f0cad2d46c3d169e00e05c2b49dc8c 100644 (file)
 #include <config.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 <iostream>
 
-using isc::dhcp::bench::GenericHostDataSourceBenchmark;
-using isc::dhcp::test::createMySQLSchema;
-using isc::dhcp::test::destroyMySQLSchema;
-using isc::dhcp::HostDataSourceFactory;
-using isc::dhcp::test::validMySQLConnectionString;
-using std::cerr;
-using std::endl;
+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 MySQL host backend
 class MySqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
 public:
+
+    /// @brief Setup routine.
+    ///
+    /// It cleans up schema and recreates tables, then instantiates LeaseMgr
     void SetUp(::benchmark::State const&) override {
         destroyMySQLSchema(false);
         createMySQLSchema(false);
@@ -47,6 +50,7 @@ public:
         hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
     }
 
+    /// @brief Cleans up after the test.
     void TearDown(::benchmark::State const&) override {
         try {
             hdsptr_->rollback();
@@ -60,6 +64,8 @@ public:
     }
 };
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts insertion.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -68,6 +74,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, insertHosts)(benchmark::State&
     }
 }
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts update.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -76,6 +84,8 @@ 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()) {
@@ -84,6 +94,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::
     }
 }
 
+/// 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) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -92,6 +104,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAll)(benchmark::State& state
     }
 }
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts retrieval by getAll(v4-reservation) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -100,6 +114,8 @@ 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()) {
@@ -108,6 +124,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchma
     }
 }
 
+/// 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) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -116,6 +134,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchma
     }
 }
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts retrieval by get4(subnet-id, v4-reservation) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -124,6 +144,8 @@ 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()) {
@@ -132,6 +154,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchma
     }
 }
 
+/// 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) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -140,6 +164,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchma
     }
 }
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts retrieval by get6(subnet-id, ip-address) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -148,6 +174,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::St
     }
 }
 
+/// Defines steps necessary for conducting a benchmark that measures
+/// hosts retrieval by get6(ip-prefix, prefix-len) call.
 BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) {
     const size_t host_count = state.range(0);
     while (state.KeepRunning()) {
@@ -156,21 +184,64 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s
     }
 }
 
-constexpr size_t MIN_HOST_COUNT = 512;
-constexpr size_t MAX_HOST_COUNT = 0xfffd;
-constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
-
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
 
 }  // namespace
index 1bbe6151fee15427cc5d66a798845b918c25ce33..0c88e25585e2869de2e648182daa17a826fe00f8 100644 (file)
 #include <config.h>
 
 #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;
+using namespace isc::dhcp;
 using namespace std;
-using isc::dhcp::LeaseMgrFactory;
-//using isc::dhcp::bench::GenericLeaseMgrBenchmark;
 
 namespace {
 
diff --git a/src/lib/dhcpsrv/benchmarks/parameters.h b/src/lib/dhcpsrv/benchmarks/parameters.h
new file mode 100644 (file)
index 0000000..5a321a7
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef BENCHMARKS_PARAMETERS_H
+#define BENCHMARKS_PARAMETERS_H
+
+#include <benchmark/benchmark.h>
+
+namespace isc {
+namespace dhcp {
+namespace bench {
+
+/// @defgroup benchmark_params Benchmark parameters that define boundary values
+///           for benchmarks.
+///
+/// The range is defined as 512..65533. Google benchmark will pick a few specifc
+/// values: 512, 4096, 32768, 65533.
+
+/// @{
+
+/// @brief A minimum number of leases used in a benchmark
+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
+constexpr size_t MIN_HOST_COUNT = 512;
+/// @brief A maximum number of leases used in a benchmark
+constexpr size_t MAX_HOST_COUNT = 0xfffd;
+
+/// @brief A time unit used - all results to be expressed in us (microseconds)
+constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
+
+/// @}
+
+};
+};
+};
+
+#endif
index eac80949605a6e876e3dadb38b3e60bf183f7d7b..5245e9d6d8c5e74cf4d84fb615fc8e8851a06624 100644 (file)
 #include <config.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/pgsql_schema.h>
-
 #include <iostream>
 
-using isc::dhcp::bench::GenericHostDataSourceBenchmark;
-using isc::dhcp::test::createPgSQLSchema;
-using isc::dhcp::test::destroyPgSQLSchema;
-using isc::dhcp::HostDataSourceFactory;
-using isc::dhcp::test::validPgSQLConnectionString;
-using std::cerr;
-using std::endl;
+using namespace isc::dhcp::bench;
+using namespace isc::dhcp::test;
+using namespace isc::dhcp;
+using namespace std;
 
 namespace {
 
@@ -156,21 +153,64 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s
     }
 }
 
-constexpr size_t MIN_HOST_COUNT = 512;
-constexpr size_t MAX_HOST_COUNT = 0xfffd;
-constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
-
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
+
+/// 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);
 
 }  // namespace
index d73c1b5abe1a7ee8c2dee3584ca350b974227a92..4080b6a2d93a095e8e24ae7b9904b27b6a088378 100644 (file)
 #include <config.h>
 
 #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 isc::dhcp::LeaseMgrFactory;
-using isc::dhcp::bench::GenericLeaseMgrBenchmark;
-using isc::dhcp::test::createPgSQLSchema;
-using isc::dhcp::test::destroyPgSQLSchema;
-using isc::dhcp::test::validPgSQLConnectionString;
-using std::cerr;
-using std::endl;
+using namespace isc::dhcp;
+using namespace isc::dhcp::test;
+using namespace std;
 
 namespace {