Commit 29440ea0 authored by Andrei Pavel's avatar Andrei Pavel

Google Benchmark support

ReentrantSetUp* methods are needed because you can't control iteration
count
Usage:
  ./configure --with-benchmark
      OR
  ./configure --with-benchmark-source=/path/to/benchmark/src

  make
  cd src/lib/dhcpsrv/benchmarks

  ./run-benchmarks
      OR
  ./run-benchmarks --benchmark_filter="RegExP*"
parent 381ad791
...@@ -45,4 +45,3 @@ config.h.in~ ...@@ -45,4 +45,3 @@ config.h.in~
/logger_lockfile /logger_lockfile
/report.info /report.info
/ext/gtest/
...@@ -588,6 +588,19 @@ if test "$lcov" != "no"; then ...@@ -588,6 +588,19 @@ if test "$lcov" != "no"; then
fi fi
AC_SUBST(USE_LCOV) AC_SUBST(USE_LCOV)
enable_benchmark="no"
BENCHMARK_INCLUDES=
AC_ARG_WITH([benchmark-source],
[AS_HELP_STRING([--with-benchmark-source=PATH],
[location of the benchmark source])],
[enable_benchmark="yes" ; BENCHMARK_SOURCE="$withval"])
AC_ARG_WITH([benchmark],
[AS_HELP_STRING([--with-benchmark=PATH],
[specify a path to benchmark header files (PATH/include) and library (PATH/lib)])],
[benchmark_path="$withval"; enable_benchmark="yes"], [benchmark_path="no"])
# Simplified, non-caching AC_CHECK_PROG # Simplified, non-caching AC_CHECK_PROG
# Searches $PATH for the existence of argument 2, # Searches $PATH for the existence of argument 2,
# and sets the full path to the variable in argument 1. # and sets the full path to the variable in argument 1.
...@@ -1338,6 +1351,106 @@ AC_SUBST(GTEST_LDFLAGS) ...@@ -1338,6 +1351,106 @@ AC_SUBST(GTEST_LDFLAGS)
AC_SUBST(GTEST_LDADD) AC_SUBST(GTEST_LDADD)
AC_SUBST(GTEST_SOURCE) AC_SUBST(GTEST_SOURCE)
#
# Check availability of benchmark.
#
BENCHMARK_LDFLAGS=
BENCHMARK_LDADD=
DISTCHECK_BENCHMARK_CONFIGURE_FLAG=
BENCHMARK_VERSION="unknown"
if test "x$enable_benchmark" = "xyes" ; then
DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark=$benchmark_path"
if test -n "$with_benchmark_source" ; then
if test "x$BENCHMARK_SOURCE" = "xyes" ; then
AC_MSG_CHECKING([for benchmark source])
# If not specified, try some common paths.
BENCHMARK_SOURCE=
for d in /usr/src/benchmark /usr/local /usr/pkg /opt /opt/local ; do
if test -f $d/src/benchmark.cc; then
BENCHMARK_SOURCE=$d
AC_MSG_RESULT([$BENCHMARK_SOURCE])
break
fi
done
if test -z $BENCHMARK_SOURCE ; then
AC_MSG_ERROR([no benchmark source but it was selected])
fi
else
if test ! -d $BENCHMARK_SOURCE/src; then
BENCHMARK_SOURCE=$BENCHMARK_SOURCE/benchmark
fi
AC_CHECK_FILES([$BENCHMARK_SOURCE/src/benchmark.cc],
[have_benchmark_source=yes],
[AC_MSG_ERROR([no benchmark source at $BENCHMARK_SOURCE])])
fi
have_benchmark_source=yes
BENCHMARK_LDADD="\$(top_builddir)/ext/benchmark/libbenchmark.a"
DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark-source=$BENCHMARK_SOURCE"
BENCHMARK_INCLUDES="-I$BENCHMARK_SOURCE \
-I$BENCHMARK_SOURCE/src \
-I$BENCHMARK_SOURCE/include \
-I$BENCHMARK_SOURCE/include/benchmark"
BENCHMARK_VERSION="$(basename $BENCHMARK_SOURCE)"
fi
if test "$benchmark_path" != "no" ; then
if test "$benchmark_path" != "yes"; then
BENCHMARK_PATHS=$benchmark_path
if test -x "${benchmark_path}/bin/benchmark-config" ; then
BENCHMARK_CONFIG="${benchmark_path}/bin/benchmark-config"
fi
else
AC_PATH_PROG([BENCHMARK_CONFIG], [benchmark-config])
fi
if test -x "${BENCHMARK_CONFIG}" ; then :
# using cppflags instead of cxxflags
BENCHMARK_INCLUDES=$(${BENCHMARK_CONFIG} --cppflags)
BENCHMARK_LDFLAGS=$(${BENCHMARK_CONFIG} --ldflags)
BENCHMARK_LDADD=$(${BENCHMARK_CONFIG} --libs)
BENCHMARK_VERSION=$(${BENCHMARK_CONFIG} --version)
BENCHMARK_FOUND="true"
else
AC_MSG_WARN([Unable to locate Google Benchmark benchmark-config.])
if test -z "${BENCHMARK_PATHS}" ; then
BENCHMARK_PATHS="/usr /usr/local"
fi
BENCHMARK_FOUND="false"
fi
if test "${BENCHMARK_FOUND}" != "true"; then
BENCHMARK_FOUND="false"
for dir in ${BENCHMARK_PATHS}; do
if test -f "$dir/include/benchmark/benchmark.h"; then
if ! test -f "$dir/lib/libbenchmark.a"; then
AC_MSG_WARN([Found Google Benchmark include but not the library in $dir.])
continue
fi
BENCHMARK_INCLUDES="-I$dir/include"
BENCHMARK_LDFLAGS="-L$dir/lib"
BENCHMARK_LDADD="$dir/lib/libbenchmark.a "
BENCHMARK_FOUND="true"
break
fi
done
fi
if test "${BENCHMARK_FOUND}" != "true"; then
AC_MSG_ERROR([Cannot find benchmark in: $BENCHMARK_PATHS])
fi
fi
fi
AM_CONDITIONAL(HAVE_BENCHMARK, test $enable_benchmark != "no")
AM_CONDITIONAL(HAVE_BENCHMARK_SOURCE, test "X$have_benchmark_source" = "Xyes")
AC_SUBST(DISTCHECK_BENCHMARK_CONFIGURE_FLAG)
AC_SUBST(BENCHMARK_INCLUDES)
AC_SUBST(BENCHMARK_LDFLAGS)
AC_SUBST(BENCHMARK_LDADD)
AC_SUBST(BENCHMARK_SOURCE)
# #
# Some Googletest versions bug with C++11 compilers # Some Googletest versions bug with C++11 compilers
# #
...@@ -1578,6 +1691,7 @@ AC_CONFIG_FILES([Makefile ...@@ -1578,6 +1691,7 @@ AC_CONFIG_FILES([Makefile
doc/version.ent doc/version.ent
ext/Makefile ext/Makefile
ext/coroutine/Makefile ext/coroutine/Makefile
ext/benchmark/Makefile
ext/gtest/Makefile ext/gtest/Makefile
m4macros/Makefile m4macros/Makefile
src/Makefile src/Makefile
...@@ -1656,6 +1770,7 @@ AC_CONFIG_FILES([Makefile ...@@ -1656,6 +1770,7 @@ AC_CONFIG_FILES([Makefile
src/lib/dhcp_ddns/Makefile src/lib/dhcp_ddns/Makefile
src/lib/dhcp_ddns/tests/Makefile src/lib/dhcp_ddns/tests/Makefile
src/lib/dhcpsrv/Makefile src/lib/dhcpsrv/Makefile
src/lib/dhcpsrv/benchmarks/Makefile
src/lib/dhcpsrv/tests/Makefile src/lib/dhcpsrv/tests/Makefile
src/lib/dhcpsrv/tests/test_libraries.h src/lib/dhcpsrv/tests/test_libraries.h
src/lib/dhcpsrv/testutils/Makefile src/lib/dhcpsrv/testutils/Makefile
...@@ -1919,6 +2034,18 @@ GTest: ...@@ -1919,6 +2034,18 @@ GTest:
END END
fi fi
if test "$enable_benchmark" != "no"; then
cat >> config.report << END
Google Benchmark:
BENCHMARK_VERSION: ${BENCHMARK_VERSION}
BENCHMARK_INCLUDES: ${BENCHMARK_INCLUDES}
BENCHMARK_LDFLAGS: ${BENCHMARK_LDFLAGS}
BENCHMARK_LDADD: ${BENCHMARK_LDADD}
BENCHMARK_SOURCE: ${BENCHMARK_SOURCE}
END
fi
cat >> config.report << END cat >> config.report << END
Developer: Developer:
......
/benchmark
/gtest
...@@ -3,3 +3,8 @@ SUBDIRS = coroutine ...@@ -3,3 +3,8 @@ SUBDIRS = coroutine
if HAVE_GTEST_SOURCE if HAVE_GTEST_SOURCE
SUBDIRS += gtest SUBDIRS += gtest
endif endif
if HAVE_BENCHMARK_SOURCE
SUBDIRS += benchmark
endif
SUBDIRS = .
CLEANFILES = benchmark.cc
noinst_LIBRARIES = libbenchmark.a
libbenchmark_a_CXXFLAGS = $(BENCHMARK_INCLUDES) $(AM_CXXFLAGS)
nodist_libbenchmark_a_SOURCES = benchmark.cc
benchmark.cc: $(BENCHMARK_SOURCE)/src/benchmark.cc
cp -p $(BENCHMARK_SOURCE)/src/benchmark.cc $@
AUTOMAKE_OPTIONS = subdir-objects AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = . testutils tests SUBDIRS = . testutils tests benchmarks
dhcp_data_dir = @localstatedir@/@PACKAGE@ dhcp_data_dir = @localstatedir@/@PACKAGE@
kea_lfc_location = @prefix@/sbin/kea-lfc kea_lfc_location = @prefix@/sbin/kea-lfc
......
SUBDIRS = .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS = -static
endif
CLEANFILES = *.gcno *.gcda
BENCHMARKS=
if HAVE_BENCHMARK
BENCHMARKS += run-benchmarks
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
if HAVE_MYSQL
run_benchmarks_SOURCES += mysql_lease_mgr_benchmark.cc
run_benchmarks_SOURCES += mysql_host_data_source_benchmark.cc
endif
if HAVE_PGSQL
run_benchmarks_SOURCES += pgsql_lease_mgr_benchmark.cc
run_benchmarks_SOURCES += pgsql_host_data_source_benchmark.cc
endif
if HAVE_CQL
run_benchmarks_SOURCES += cql_lease_mgr_benchmark.cc
run_benchmarks_SOURCES += cql_host_data_source_benchmark.cc
endif
run_benchmarks_CPPFLAGS = $(AM_CPPFLAGS) $(BENCHMARK_INCLUDES) -Wno-error=overloaded-virtual
if HAVE_MYSQL
run_benchmarks_CPPFLAGS += $(MYSQL_CPPFLAGS)
endif
if HAVE_PGSQL
run_benchmarks_CPPFLAGS += $(PGSQL_CPPFLAGS)
endif
if HAVE_CQL
run_benchmarks_CPPFLAGS += $(CQL_CPPFLAGS)
endif
run_benchmarks_CXXFLAGS = $(AM_CXXFLAGS)
run_benchmarks_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(BENCHMARK_LDFLAGS)
if HAVE_MYSQL
run_benchmarks_LDFLAGS += $(MYSQL_LIBS)
endif
if HAVE_PGSQL
run_benchmarks_LDFLAGS += $(PGSQL_LIBS)
endif
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/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
endif
noinst_PROGRAMS = $(BENCHMARKS)
// Copyright (C) 2017 Deutsche Telekom AG.
//
// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <config.h>
#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.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;
namespace {
class CqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
public:
void SetUp(::benchmark::State const&) override {
destroyCqlSchema(false, true);
createCqlSchema(false, true);
try {
HostDataSourceFactory::destroy();
HostDataSourceFactory::create(validCqlConnectionString());
} catch (...) {
cerr << "ERROR: unable to open database" << endl;
throw;
}
hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr();
}
void TearDown(::benchmark::State const&) override {
try {
hdsptr_->rollback();
} catch (...) {
cerr << "WARNING: rollback has failed, this is expected if database"
" is opened in read-only mode, continuing..."
<< endl;
}
HostDataSourceFactory::destroy();
destroyCqlSchema(false, true);
}
};
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp(state, host_count);
insertHosts();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
updateHosts();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll2)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
getAll2();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
getAll3();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll1)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
getAll1();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
get4_3();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_4)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
get4_4();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4_2)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
get4_2();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_3)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
get6_3();
}
}
BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6_4)(benchmark::State& state) {
const size_t host_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts(state, host_count);
get6_4();
}
}
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);
get6_2_subnetid_address();
}
}
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);
get6_2_prefix_prefixlen();
}
}
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, getAll2)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll3)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll1)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4_3)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4_4)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4_2)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6_3)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6_4)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6_2_subnetid_address)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6_2_prefix_prefixlen)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
} // namespace
// Copyright (C) 2017 Deutsche Telekom AG.
//
// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <config.h>
#include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
#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;
namespace {
class CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
public:
void SetUp(::benchmark::State const&) override {
destroyCqlSchema(false, true);
createCqlSchema(false, true);
try {
LeaseMgrFactory::destroy();
LeaseMgrFactory::create(validCqlConnectionString());
} catch (...) {
cerr << "ERROR: unable to open database" << endl;
throw;
}
lmptr_ = &(LeaseMgrFactory::instance());
}
void TearDown(::benchmark::State const&) override {
try {
lmptr_->rollback();
} catch (...) {
cerr << "WARNING: rollback has failed, this is expected if database"
" is opened in read-only mode, continuing..."
<< endl;
}
LeaseMgrFactory::destroy();
destroyCqlSchema(false, true);
}
};
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp4(state, lease_count);
insertLeases4();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
updateLeases4();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
getLease4_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);
getLease4_hwaddr();
}
}
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);
getLease4_hwaddr_subnetid();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
getLease4_clientid();
}
}
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);
getLease4_clientid_subnetid();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts4(state, lease_count);
getExpiredLeases4();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUp6(state, lease_count);
insertLeases6();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
updateLeases6();
}
}
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);
getLease6_type_address();
}
}
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);
getLease6_type_duid_iaid();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_type_duid_iaid_subnetid)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
getLease6_type_type_duid_iaid_subnetid();
}
}
BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
const size_t lease_count = state.range(0);
while (state.KeepRunning()) {
ReentrantSetUpWithInserts6(state, lease_count);
getExpiredLeases6();
}
}
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);