#include <config.h>
-#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
-
#include <asiolink/io_address.h>
+
+#include <database/testutils/schema.h>
+
#include <dhcp/dhcp6.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option4_addrlst.h>
#include <dhcp/option_int.h>
#include <dhcp/option_string.h>
#include <dhcp/option_vendor.h>
+
+#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
#include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/schema.h>
#include <dhcpsrv/testutils/host_data_source_utils.h>
using isc::asiolink::IOAddress;
namespace dhcp {
namespace bench {
-GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark()
- : hdsptr_() {
+GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark() : hdsptr_() {
LibDHCP::clearRuntimeOptionDefs();
}
}
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);
}
void
-GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool formatted,
+GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host,
+ const bool formatted,
const AddedOptions& added_options) const {
OptionDefSpaceContainer defs;
// Add DHCPv4 options.
CfgOptionPtr opts = host->getCfgOption4();
opts->add(createOption<OptionString>(Option::V4, DHO_BOOT_FILE_NAME, true, formatted,
- "my-boot-file"), DHCP4_OPTION_SPACE);
- opts->add(createOption<OptionUint8>(Option::V4, DHO_DEFAULT_IP_TTL,
- false, formatted, 64), DHCP4_OPTION_SPACE);
+ "my-boot-file"),
+ DHCP4_OPTION_SPACE);
+ opts->add(createOption<OptionUint8>(Option::V4, DHO_DEFAULT_IP_TTL, false, formatted, 64),
+ DHCP4_OPTION_SPACE);
opts->add(createOption<OptionUint32>(Option::V4, 1, false, formatted, 312131),
"vendor-encapsulated-options");
opts->add(createAddressOption<Option4AddrLst>(254, false, formatted, "192.0.2.3"),
DHCP4_OPTION_SPACE);
opts->add(createEmptyOption(Option::V4, 1, true), "isc");
- opts->add(createAddressOption<Option4AddrLst>(2, false, formatted, "10.0.0.5",
- "10.0.0.3", "10.0.3.4"), "isc");
+ opts->add(createAddressOption<Option4AddrLst>(2, false, formatted, "10.0.0.5", "10.0.0.3",
+ "10.0.3.4"),
+ "isc");
// Add definitions for DHCPv4 non-standard options.
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", 1,
- "uint32")), "vendor-encapsulated-options");
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-254", 254, "ipv4-address",
- true)), DHCP4_OPTION_SPACE);
+ defs.addItem(
+ OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", 1, "uint32")),
+ "vendor-encapsulated-options");
+ defs.addItem(
+ OptionDefinitionPtr(new OptionDefinition("option-254", 254, "ipv4-address", true)),
+ DHCP4_OPTION_SPACE);
defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "empty")), "isc");
defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "ipv4-address", true)),
"isc");
if ((added_options == DHCP6_ONLY) || (added_options == DHCP4_AND_DHCP6)) {
// Add DHCPv6 options.
CfgOptionPtr opts = host->getCfgOption6();
- opts->add(createOption<OptionString>(Option::V6, D6O_BOOTFILE_URL, true,
- formatted, "my-boot-file"), DHCP6_OPTION_SPACE);
- opts->add(createOption<OptionUint32>(Option::V6, D6O_INFORMATION_REFRESH_TIME,
- false, formatted, 3600), DHCP6_OPTION_SPACE);
+ opts->add(createOption<OptionString>(Option::V6, D6O_BOOTFILE_URL, true, formatted,
+ "my-boot-file"),
+ DHCP6_OPTION_SPACE);
+ opts->add(createOption<OptionUint32>(Option::V6, D6O_INFORMATION_REFRESH_TIME, false,
+ formatted, 3600),
+ DHCP6_OPTION_SPACE);
opts->add(createVendorOption(Option::V6, false, formatted, 2495), DHCP6_OPTION_SPACE);
opts->add(createAddressOption<Option6AddrLst>(1024, false, formatted, "2001:db8:1::1"),
DHCP6_OPTION_SPACE);
opts->add(createEmptyOption(Option::V6, 1, true), "isc2");
opts->add(createAddressOption<Option6AddrLst>(2, false, formatted, "3000::1", "3000::2",
- "3000::3"), "isc2");
+ "3000::3"),
+ "isc2");
// Add definitions for DHCPv6 non-standard options.
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1024", 1024, "ipv6-address",
- true)), DHCP6_OPTION_SPACE);
+ defs.addItem(
+ OptionDefinitionPtr(new OptionDefinition("option-1024", 1024, "ipv6-address", true)),
+ DHCP6_OPTION_SPACE);
defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "empty")), "isc2");
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address",
- true)), "isc2");
+ defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address", true)),
+ "isc2");
}
// Register created "runtime" option definitions. They will be used by a
GenericHostDataSourceBenchmark::benchGet4IdentifierSubnetId() {
for (HostPtr host : hosts_) {
std::vector<uint8_t> hwaddr = host->getIdentifier();
- hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(),
- &hwaddr[0], hwaddr.size());
+ hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(), &hwaddr[0],
+ hwaddr.size());
}
}
GenericHostDataSourceBenchmark::benchGet6IdentifierSubnetId() {
for (HostPtr host : hosts_) {
std::vector<uint8_t> hwaddr = host->getIdentifier();
- hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(),
- &hwaddr[0], hwaddr.size());
+ hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(), &hwaddr[0],
+ hwaddr.size());
}
}
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());
}
}
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
};
/// @param address3 third address to be used (optional)
/// @return the option created wrapped in an option descriptor structure
template <typename OptionType>
- OptionDescriptor
- createAddressOption(const uint16_t option_type, const bool persist,
- const bool formatted, const std::string& address1 = "",
- const std::string& address2 = "",
- const std::string& address3 = "") const {
+ OptionDescriptor createAddressOption(const uint16_t option_type,
+ const bool persist,
+ const bool formatted,
+ const std::string& address1 = "",
+ const std::string& address2 = "",
+ const std::string& address3 = "") const {
std::ostringstream s;
// First address.
/// @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.