From: Razvan Becheriu Date: Tue, 5 Mar 2019 16:06:52 +0000 (+0200) Subject: fixed benchmarks X-Git-Tag: Kea-1.6.0-beta~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff7808908907d4d4d7f8ed372cc52ac076a6e11b;p=thirdparty%2Fkea.git fixed benchmarks --- diff --git a/src/lib/dhcpsrv/benchmarks/Makefile.am b/src/lib/dhcpsrv/benchmarks/Makefile.am index c99b884fac..14c52a5c2b 100644 --- a/src/lib/dhcpsrv/benchmarks/Makefile.am +++ b/src/lib/dhcpsrv/benchmarks/Makefile.am @@ -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) diff --git a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc index 3e25aa3b17..5cdbc0d1f8 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc @@ -17,23 +17,24 @@ #include +#include + #include #include #include -#include +#include + #include -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 diff --git a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc index 4fa64ecd4f..934605f833 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc @@ -17,21 +17,21 @@ #include +#include + #include #include #include -#include +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 diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc index ed944b0871..00e9e0af41 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc @@ -17,9 +17,10 @@ #include -#include - #include + +#include + #include #include #include @@ -27,8 +28,9 @@ #include #include #include + +#include #include -#include #include 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(Option::V4, DHO_BOOT_FILE_NAME, true, formatted, - "my-boot-file"), DHCP4_OPTION_SPACE); - opts->add(createOption(Option::V4, DHO_DEFAULT_IP_TTL, - false, formatted, 64), DHCP4_OPTION_SPACE); + "my-boot-file"), + DHCP4_OPTION_SPACE); + opts->add(createOption(Option::V4, DHO_DEFAULT_IP_TTL, false, formatted, 64), + DHCP4_OPTION_SPACE); opts->add(createOption(Option::V4, 1, false, formatted, 312131), "vendor-encapsulated-options"); opts->add(createAddressOption(254, false, formatted, "192.0.2.3"), DHCP4_OPTION_SPACE); opts->add(createEmptyOption(Option::V4, 1, true), "isc"); - opts->add(createAddressOption(2, false, formatted, "10.0.0.5", - "10.0.0.3", "10.0.3.4"), "isc"); + opts->add(createAddressOption(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(Option::V6, D6O_BOOTFILE_URL, true, - formatted, "my-boot-file"), DHCP6_OPTION_SPACE); - opts->add(createOption(Option::V6, D6O_INFORMATION_REFRESH_TIME, - false, formatted, 3600), DHCP6_OPTION_SPACE); + opts->add(createOption(Option::V6, D6O_BOOTFILE_URL, true, formatted, + "my-boot-file"), + DHCP6_OPTION_SPACE); + opts->add(createOption(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(1024, false, formatted, "2001:db8:1::1"), DHCP6_OPTION_SPACE); opts->add(createEmptyOption(Option::V6, 1, true), "isc2"); opts->add(createAddressOption(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 hwaddr = host->getIdentifier(); - hdsptr_->get4(host->getIPv4SubnetID(), HWAddrPtr(new HWAddr(hwaddr, - host->getIdentifierType())), host->getDuid()); - } -} - void GenericHostDataSourceBenchmark::benchGet4IdentifierSubnetId() { for (HostPtr host : hosts_) { std::vector 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 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()); } } diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h index 8521bcb09e..d445e55a27 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h +++ b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h @@ -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 - 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(); diff --git a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc index 19160a2b82..7cb0bf0b3a 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc @@ -18,9 +18,7 @@ #include #include - #include -#include #include #include @@ -29,7 +27,6 @@ #include 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_); } } diff --git a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h index eb4de3926e..d636e28cca 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h +++ b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h @@ -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 }; diff --git a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc index ce6e738af5..2afe5f4205 100644 --- a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include 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 diff --git a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc index 3b93a66614..97c7652dab 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc @@ -17,23 +17,24 @@ #include +#include + #include #include #include -#include +#include + #include -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 diff --git a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc index 9353557bce..7d59ad4558 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc @@ -20,18 +20,18 @@ #include #include #include -#include -using namespace isc::dhcp::bench; -using namespace isc::dhcp::test; +#include + +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 diff --git a/src/lib/dhcpsrv/benchmarks/parameters.h b/src/lib/dhcpsrv/benchmarks/parameters.h index 2de54f93ce..2f54c28351 100644 --- a/src/lib/dhcpsrv/benchmarks/parameters.h +++ b/src/lib/dhcpsrv/benchmarks/parameters.h @@ -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 diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc index c57aa1e6a6..ef3d6b7f4d 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc @@ -20,20 +20,21 @@ #include #include #include -#include +#include + +#include + #include +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 diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc index 05f2429bd2..f9d0c89807 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc @@ -20,18 +20,18 @@ #include #include #include -#include -using namespace isc::dhcp::bench; -using namespace isc::dhcp::test; +#include + +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 diff --git a/src/lib/dhcpsrv/benchmarks/run_benchmarks.cc b/src/lib/dhcpsrv/benchmarks/run_benchmarks.cc index bcc4a536a9..35ac2c33b3 100644 --- a/src/lib/dhcpsrv/benchmarks/run_benchmarks.cc +++ b/src/lib/dhcpsrv/benchmarks/run_benchmarks.cc @@ -20,8 +20,7 @@ #include /// @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();