Commit 86980fa9 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[github36] Large chunk of review work completed:

 - common code extracted to testutils/host_data_source_utils.cc|h
 - doxygen comments written
 - compilation warnings removed
 - each leasemgr benchmark have at least a short description
 - HostDataSource benchmarks partially done, but still WIP
 - overall, the diff is 4k and counting...
parent 033b9560
......@@ -1634,13 +1634,18 @@ fi
if test "$enable_gtest" != "no"; then
cat >> config.report << END
GTest:
Google Test:
GTEST_VERSION: ${GTEST_VERSION}
GTEST_INCLUDES: ${GTEST_INCLUDES}
GTEST_LDFLAGS: ${GTEST_LDFLAGS}
GTEST_LDADD: ${GTEST_LDADD}
GTEST_SOURCE: ${GTEST_SOURCE}
END
else
cat >> config.report << END
Google Test:
no
END
fi
if test "$enable_benchmark" != "no"; then
......@@ -1653,6 +1658,11 @@ Google Benchmark:
BENCHMARK_LDADD: ${BENCHMARK_LDADD}
BENCHMARK_SOURCE: ${BENCHMARK_SOURCE}
END
else
cat >> config.report << END
Google Benchmark:
no
END
fi
cat >> config.report << END
......
......@@ -17,7 +17,7 @@ if HAVE_PGSQL
AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
if HAVE_CQL
AM_CPPFLAGS += $(CQL_CPPFLAGS)
AM_CPPFLAGS += $(CQL_CPPFLAGS) $(CRYPTO_INCLUDES)
endif
AM_CXXFLAGS = $(KEA_CXXFLAGS)
......
......@@ -69,14 +69,16 @@ if HAVE_CQL
run_benchmarks_LDFLAGS += $(CQL_LIBS)
endif
run_benchmarks_LDADD = $(BENCHMARK_LDADD)
run_benchmarks_LDADD += $(LOG4CPLUS_LIBS)
run_benchmarks_LDADD += $(CRYPTO_LIBS)
run_benchmarks_LDADD += $(BOOST_LIBS)
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/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)
endif
noinst_PROGRAMS = $(BENCHMARKS)
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017 Deutsche Telekom AG.
//
// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
......@@ -32,8 +33,11 @@ using std::endl;
namespace {
/// @brief Fixture class for benchmarking Cassandra host backend
class CqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
public:
/// @brief Before benchmark setup.
void SetUp(::benchmark::State const&) override {
destroyCqlSchema(false, true);
createCqlSchema(false, true);
......@@ -47,6 +51,7 @@ public:
hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
}
/// @brief After benchmark clean-up
void TearDown(::benchmark::State const&) override {
try {
hdsptr_->rollback();
......@@ -60,26 +65,29 @@ public:
}
};
// This benchmark measures insertion of new hosts.
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp(state, host_count);
setUp(state, host_count);
insertHosts();
}
}
// This benchmark measures update of existing hosts.
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
updateHosts();
}
}
// This benchmark
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll2)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
getAll2();
}
}
......@@ -87,7 +95,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll2)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
getAll3();
}
}
......@@ -95,7 +103,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll3)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll1)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
getAll1();
}
}
......@@ -103,7 +111,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll1)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get4_3();
}
}
......@@ -111,7 +119,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_3)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_4)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get4_4();
}
}
......@@ -119,7 +127,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_4)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_2)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get4_2();
}
}
......@@ -127,7 +135,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_2)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get6_3();
}
}
......@@ -135,7 +143,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_3)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_4)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get6_4();
}
}
......@@ -143,7 +151,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_4)(benchmark::State& state)
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_2_subnetid_address)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get6_2_subnetid_address();
}
}
......@@ -151,7 +159,7 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_2_subnetid_address)(benchmar
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_2_prefix_prefixlen)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
setUpWithInserts(state, host_count);
get6_2_prefix_prefixlen();
}
}
......
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017 Deutsche Telekom AG.
//
// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
......@@ -20,18 +21,20 @@
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/testutils/cql_schema.h>
using isc::dhcp::LeaseMgrFactory;
using isc::dhcp::bench::GenericLeaseMgrBenchmark;
using isc::dhcp::test::createCqlSchema;
using isc::dhcp::test::destroyCqlSchema;
using isc::dhcp::test::validCqlConnectionString;
using std::cerr;
using std::endl;
using namespace isc::dhcp;
using namespace isc::dhcp::test;
using namespace std;
using namespace isc::dhcp::bench;
namespace {
/// @brief This is a fixture class used for benchmarking Cassandra lease backend
class CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
public:
/// @brief Prepares the benchmark to run
///
/// Destroys and then recreates CQL schema, initializes CQL LeaseMgr.
void SetUp(::benchmark::State const&) override {
destroyCqlSchema(false, true);
createCqlSchema(false, true);
......@@ -45,6 +48,7 @@ public:
lmptr_ = &(LeaseMgrFactory::instance());
}
/// @brief Cleans up after the benchmark.
void TearDown(::benchmark::State const&) override {
try {
lmptr_->rollback();
......@@ -58,135 +62,196 @@ public:
}
};
// Defines a benchmark that measures IPv4 leases insertion.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp4(state, lease_count);
setUp4(state, lease_count);
benchInsertLeases4();
}
}
// Defines a benchmark that measures IPv4 leases update.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchUpdateLeases4();
}
}
// Defines a benchmark that measures IPv4 leases retrieval by address.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetLease4_address();
}
}
// Defines a benchmark that measures IPv4 leases retrieval by hardware address.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetLease4_hwaddr();
}
}
// Defines a benchmark that measures IPv4 leases retrieval by hardware address
// and subnet-id.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetLease4_hwaddr_subnetid();
}
}
// Defines a benchmark that measures IPv4 leases retrieval by client-id.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetLease4_clientid();
}
}
// Defines a benchmark that measures IPv4 leases retrieval by client-id and
// subnet-id.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetLease4_clientid_subnetid();
}
}
// Defines a benchmark that measures retrieval of expired IPv4 leases.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
setUpWithInserts4(state, lease_count);
benchGetExpiredLeases4();
}
}
// Defines a benchmark that measures IPv6 leases insertion.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp6(state, lease_count);
setUp6(state, lease_count);
benchInsertLeases6();
}
}
// Defines a benchmark that measures IPv6 leases update.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
setUpWithInserts6(state, lease_count);
benchUpdateLeases6();
}
}
// Defines a benchmark that measures IPv6 leases retrieval by type and address.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
setUpWithInserts6(state, lease_count);
benchGetLease6_type_address();
}
}
// Defines a benchmark that measures IPv6 leases retrieval by type, duid and iaid.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
setUpWithInserts6(state, lease_count);
benchGetLease6_type_duid_iaid();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_type_duid_iaid_subnetid)(benchmark::State& state) {
// 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) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
setUpWithInserts6(state, lease_count);
benchGetLease6_type_duid_iaid_subnetid();
}
}
// Defines a benchmark that measures retrieval of expired IPv6 leases.
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
setUpWithInserts6(state, lease_count);
benchGetExpiredLeases6();
}
}
constexpr size_t MIN_LEASE_COUNT = 512;
constexpr size_t MAX_LEASE_COUNT = 0xfffd;
constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases4)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases4)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_address)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid_subnetid)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases4)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases6)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases6)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_address)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_type_duid_iaid_subnetid)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases6)->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
/// 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);
/// A benchmark that measures IPv4 leases update.
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases4)
->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);
/// 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);
/// 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);
/// 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);
/// 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);
/// A benchmark that measures expired IPv4 leases retrieval.
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases4)
->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);
/// A benchmark that measures IPv6 leases update.
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases6)
->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);
/// 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);
/// 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);
/// A benchmark that measures expired IPv6 leases retrieval.
BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases6)
->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
} // namespace
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017 Deutsche Telekom AG.
//
// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
......@@ -28,8 +29,10 @@
#include <dhcp/option_vendor.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;
using isc::dhcp::test::HostDataSourceUtils;
using std::cerr;
using std::endl;
......@@ -48,8 +51,8 @@ GenericHostDataSourceBenchmark::~GenericHostDataSourceBenchmark() {
}
void
GenericHostDataSourceBenchmark::ReentrantSetUp(::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);
......@@ -57,8 +60,8 @@ GenericHostDataSourceBenchmark::ReentrantSetUp(::benchmark::State& state,
}
void
GenericHostDataSourceBenchmark::ReentrantSetUpWithInserts(::benchmark::State& state,
size_t const& host_count) {
GenericHostDataSourceBenchmark::setUpWithInserts(::benchmark::State& state,
size_t const& host_count) {
state.PauseTiming();
SetUp(state);
prepareHosts(host_count);
......@@ -66,107 +69,6 @@ GenericHostDataSourceBenchmark::ReentrantSetUpWithInserts(::benchmark::State& st
state.ResumeTiming();
}
std::vector<uint8_t>
GenericHostDataSourceBenchmark::generateHWAddr(const bool new_identifier) {
/// @todo: Consider moving this somewhere to lib/testutils.
// Let's use something that is easily printable. That's convenient
// if you need to enter MySQL queries by hand.
static uint8_t hwaddr[] = {65, 66, 67, 68, 69, 70};
if (new_identifier) {
// Increase the address for the next time we use it.
// This is primitive, but will work for 65k unique addresses.
hwaddr[sizeof(hwaddr) - 1]++;
if (hwaddr[sizeof(hwaddr) - 1] == 0) {
hwaddr[sizeof(hwaddr) - 2]++;
}
}
return std::vector<uint8_t>(hwaddr, hwaddr + sizeof(hwaddr));
}
std::vector<uint8_t>
GenericHostDataSourceBenchmark::generateIdentifier(const bool new_identifier) {
/// @todo: Consider moving this somewhere to lib/testutils.
// Let's use something that is easily printable. That's convenient
// if you need to enter MySQL queries by hand.
static uint8_t ident[] = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74};
if (new_identifier) {
// Increase the identifier for the next time we use it.
// This is primitive, but will work for 65k unique identifiers.
ident[sizeof(ident) - 1]++;
if (ident[sizeof(ident) - 1] == 0) {
ident[sizeof(ident) - 2]++;
}
}
return std::vector<uint8_t>(ident, ident + sizeof(ident));
}
HostPtr
GenericHostDataSourceBenchmark::initializeHost4(const std::string& address,
const Host::IdentifierType& id) {
std::vector<uint8_t> ident;
if (id == Host::IDENT_HWADDR) {
ident = generateHWAddr();
} else {
ident = generateIdentifier();
}
// Let's create ever increasing subnet-ids. Let's keep those different,
// so subnet4 != subnet6. Useful for catching cases if the code confuses
// subnet4 with subnet6.
static SubnetID subnet4 = 0;
static SubnetID subnet6 = 100;
++subnet4;
++subnet6;
IOAddress addr(address);
HostPtr host(new Host(&ident[0], ident.size(), id, subnet4, subnet6, addr));
return host;
}
HostPtr
GenericHostDataSourceBenchmark::initializeHost6(std::string address,
Host::IdentifierType identifier,
bool prefix, bool new_identifier) {
std::vector<uint8_t> ident;
switch (identifier) {
case Host::IDENT_HWADDR:
ident = generateHWAddr(new_identifier);
break;
case Host::IDENT_DUID:
ident = generateIdentifier(new_identifier);
break;
default:
return HostPtr();
}
// Let's create ever increasing subnet-ids. Let's keep those different,
// so subnet4 != subnet6. Useful for catching cases if the code confuses
// subnet4 with subnet6.
static SubnetID subnet4 = 0;
static SubnetID subnet6 = 100;
subnet4++;
subnet6++;