# variables.
AX_ISC_GTEST
-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"])
-
# Sets up for use of botan unless openssl is specified
# sets variables CRYPTO_*
AX_CRYPTO
# Now that Crypto backend and Boost were done we can address TLS.
AX_TLS
-#
-# Check availability of benchmark.
-#
-BENCHMARK_CPPFLAGS=
-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
- if test -f $BENCHMARK_SOURCE/src/benchmark.cc; then
- have_benchmark_source=yes
- else
- AC_MSG_ERROR([no benchmark source at $BENCHMARK_SOURCE])
- fi
- fi
- have_benchmark_source=yes
- BENCHMARK_CPPFLAGS=`cat \${BENCHMARK_SOURCE}/build/src/CMakeFiles/benchmark.dir/flags.make | grep CXX_DEFINES | cut -d "=" -f 2`
- BENCHMARK_LDADD="\$(BENCHMARK_SOURCE)/build/src/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
- fi
- if test -z "${BENCHMARK_PATHS}" ; then
- BENCHMARK_PATHS="/usr /usr/local"
- fi
- 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
- if test "${BENCHMARK_FOUND}" != "true"; then
- AC_MSG_ERROR([Cannot find benchmark in: $BENCHMARK_PATHS])
- fi
-
- fi
-
- if test $enable_gtest = no; then
- AC_MSG_ERROR([--with-benchmark and --with-benchmark-source require --with-gtest or --with-gtest-source])
- 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_CONFIG_FILES([src/lib/dhcp_ddns/Makefile])
AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/Makefile])
-AC_CONFIG_FILES([src/lib/dhcpsrv/benchmarks/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/tests/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_libraries.h])
AC_CONFIG_FILES([src/lib/dhcpsrv/testutils/Makefile])
END
fi
-if test "$enable_benchmark" != "no"; then
-cat >> config.report << END
-
-Google Benchmark:
- BENCHMARK_VERSION: ${BENCHMARK_VERSION}
- BENCHMARK_CPPFLAGS: ${BENCHMARK_CPPFLAGS}
- BENCHMARK_INCLUDES: ${BENCHMARK_INCLUDES}
- BENCHMARK_LDFLAGS: ${BENCHMARK_LDFLAGS}
- BENCHMARK_LDADD: ${BENCHMARK_LDADD}
- BENCHMARK_SOURCE: ${BENCHMARK_SOURCE}
-END
-else
-cat >> config.report << END
-
-Google Benchmark:
- no
-END
-fi
-
if test "$FREERADIUS_INCLUDE" != ""; then
cat >> config.report << END
AUTOMAKE_OPTIONS = subdir-objects
-SUBDIRS = . testutils tests benchmarks
+SUBDIRS = . testutils tests
# DATA_DIR is the directory where to put default CSV files and the DHCPv6
# server ID file (i.e. the file where the server finds its DUID at startup).
+++ /dev/null
-/run-benchmarks
-
+++ /dev/null
-SUBDIRS = .
-
-AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
-AM_CPPFLAGS += $(BOOST_INCLUDES)
-AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dhcpsrv/tests\"
-
-AM_CXXFLAGS = $(KEA_CXXFLAGS)
-
-if USE_STATIC_LINK
-AM_LDFLAGS = -static
-endif
-
-CLEANFILES = *.gcno *.gcda
-
-EXTRA_DIST = benchmarks.dox
-
-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
-run_benchmarks_SOURCES += memfile_lease_mgr_benchmark.cc
-run_benchmarks_SOURCES += parameters.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
-
-run_benchmarks_CPPFLAGS = $(AM_CPPFLAGS) $(BENCHMARK_INCLUDES) $(BENCHMARK_CPPFLAGS)
-
-if HAVE_MYSQL
-run_benchmarks_CPPFLAGS += $(MYSQL_CPPFLAGS)
-endif
-
-if HAVE_PGSQL
-run_benchmarks_CPPFLAGS += $(PGSQL_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
-
-run_benchmarks_LDADD = $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
-
-if HAVE_MYSQL
-run_benchmarks_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
-endif
-
-if HAVE_PGSQL
-run_benchmarks_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
-endif
-
-run_benchmarks_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
-run_benchmarks_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
-
-if HAVE_MYSQL
-run_benchmarks_LDADD += $(MYSQL_LIBS)
-endif
-
-if HAVE_PGSQL
-run_benchmarks_LDADD += $(PGSQL_LIBS)
-endif
-
-run_benchmarks_LDADD += $(LOG4CPLUS_LIBS)
-run_benchmarks_LDADD += $(CRYPTO_LIBS)
-run_benchmarks_LDADD += $(BOOST_LIBS)
-run_benchmarks_LDADD += $(GTEST_LDADD)
-run_benchmarks_LDADD += $(BENCHMARK_LDADD)
-
-endif
-
-noinst_PROGRAMS = $(BENCHMARKS)
+++ /dev/null
-// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-/**
- @page benchmarks Benchmarks: Measuring performance
-
-@section benchmarksOverview
-
-Kea 1.4 added support for benchmarks. We are using
-<a href="https://github.com/google/benchmark">Google Benchmark</a>
-framework. See their webpage for overview and details.
-
-To compile benchmarks, configure Kea with appropriate flag:
-
-@code
-$ ./configure --with-benchmark
-$ make
-@endcode
-
-The benchmarks are built in @b src/lib/dhcpsrv/benchmarks directory.
-Note that the benchmarks are backend-specific, so please make sure you
-enable the backends you want to measure (See --with-mysql and --with-pgsql
-parameters for configure). Once the benchmark is built, you can run specific
-benchmarks. Make sure you have the environment ready for use, i.e. the actual
-database backend is set up, the DB is created. The setup is the same
-as for running unit-tests. DB name should be keatest, and username
-keatest, password keatest should give you full write access to the database.
-Any data present in the DB before the tests will be removed.
-
-To get a list of available benchmarks, use the following command:
-
-@code
-$ cd src/lib/dhcpsrv/benchmarks
-$ ./run-benchmarks --benchmark_list_tests
-@endcode
-
-The list is dependant on the configuration flags and availability of
-various backends. For example, to run specific benchmark you may
-specify its name. Wildcards are supported:
-
-@code
-# This will run one specific benchmark
-$ ./run-benchmarks --benchmark_filter=MemfileLeaseMgrBenchmark/insertLeases4/512
-
-# This will run all benchmarks related to MySql:
-$ ./run-benchmarks --benchmark_filter=MySqlHostDataSourceBenchmark
-
-@endcode
-
-It takes a long time to run some benchmarks, so please make sure you run only
-those you are interested in. For example, this is the output of all memfile
-benchmarks:
-
-@code
-$ ./run-benchmarks --benchmark_filter=MemfileLeaseMgrBenchmark
-Run on (8 X 3800 MHz CPU s)
-2018-01-23 21:00:19
-***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
-***WARNING*** Library was built as DEBUG. Timings may be affected.
--------------------------------------------------------------------------------------------------------------
-Benchmark Time CPU Iterations
--------------------------------------------------------------------------------------------------------------
-MemfileLeaseMgrBenchmark/insertLeases4/512 10716 us 10716 us 48
-MemfileLeaseMgrBenchmark/insertLeases4/4096 90593 us 90590 us 8
-MemfileLeaseMgrBenchmark/insertLeases4/32768 758551 us 758524 us 1
-MemfileLeaseMgrBenchmark/insertLeases4/65533 1553195 us 1553136 us 1
-MemfileLeaseMgrBenchmark/updateLeases4/512 8379 us 8379 us 84
-MemfileLeaseMgrBenchmark/updateLeases4/4096 67506 us 67504 us 10
-MemfileLeaseMgrBenchmark/updateLeases4/32768 546041 us 546024 us 1
-MemfileLeaseMgrBenchmark/updateLeases4/65533 1098839 us 1098799 us 1
-MemfileLeaseMgrBenchmark/getLease4_address/512 2772 us 2772 us 253
-MemfileLeaseMgrBenchmark/getLease4_address/4096 23407 us 23406 us 30
-MemfileLeaseMgrBenchmark/getLease4_address/32768 179624 us 179619 us 4
-MemfileLeaseMgrBenchmark/getLease4_address/65533 393543 us 393531 us 2
-MemfileLeaseMgrBenchmark/getLease4_hwaddr/512 3899 us 3898 us 181
-MemfileLeaseMgrBenchmark/getLease4_hwaddr/4096 51317 us 51316 us 12
-MemfileLeaseMgrBenchmark/getLease4_hwaddr/32768 3269266 us 3269150 us 1
-MemfileLeaseMgrBenchmark/getLease4_hwaddr/65533 13225744 us 13225237 us 1
-MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/512 3501 us 3501 us 201
-MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/4096 30573 us 30571 us 23
-MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/32768 245307 us 245295 us 3
-MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/65533 521296 us 521274 us 1
-MemfileLeaseMgrBenchmark/getLease4_clientid/512 3999 us 3999 us 175
-MemfileLeaseMgrBenchmark/getLease4_clientid/4096 75467 us 75464 us 9
-MemfileLeaseMgrBenchmark/getLease4_clientid/32768 6375617 us 6375402 us 1
-MemfileLeaseMgrBenchmark/getLease4_clientid/65533 26109513 us 26108636 us 1
-MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/512 3532 us 3532 us 198
-MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/4096 30279 us 30277 us 24
-MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/32768 244085 us 244072 us 3
-MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/65533 509971 us 509948 us 1
-MemfileLeaseMgrBenchmark/getExpiredLeases4/512 837 us 837 us 841
-MemfileLeaseMgrBenchmark/getExpiredLeases4/4096 72253 us 72251 us 8
-MemfileLeaseMgrBenchmark/getExpiredLeases4/32768 5837125 us 5836712 us 1
-MemfileLeaseMgrBenchmark/getExpiredLeases4/65533 42295069 us 42292723 us 1
-MemfileLeaseMgrBenchmark/insertLeases6/512 5638 us 5638 us 121
-MemfileLeaseMgrBenchmark/insertLeases6/4096 46669 us 46667 us 15
-MemfileLeaseMgrBenchmark/insertLeases6/32768 423543 us 423527 us 2
-MemfileLeaseMgrBenchmark/insertLeases6/65533 806061 us 806031 us 1
-MemfileLeaseMgrBenchmark/updateLeases6/512 2796 us 2796 us 231
-MemfileLeaseMgrBenchmark/updateLeases6/4096 22683 us 22681 us 31
-MemfileLeaseMgrBenchmark/updateLeases6/32768 190410 us 190403 us 4
-MemfileLeaseMgrBenchmark/updateLeases6/65533 382458 us 382441 us 2
-MemfileLeaseMgrBenchmark/getLease6_type_address/512 2824 us 2824 us 246
-MemfileLeaseMgrBenchmark/getLease6_type_address/4096 23483 us 23482 us 30
-MemfileLeaseMgrBenchmark/getLease6_type_address/32768 198815 us 198800 us 4
-MemfileLeaseMgrBenchmark/getLease6_type_address/65533 369424 us 369408 us 2
-MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/512 3859 us 3858 us 183
-MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/4096 32180 us 32178 us 23
-MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/32768 252381 us 252372 us 3
-MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/65533 508467 us 508449 us 2
-MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/512 4085 us 4085 us 170
-MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/4096 32983 us 32981 us 21
-MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/32768 257658 us 257648 us 3
-MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/65533 514603 us 514583 us 1
-MemfileLeaseMgrBenchmark/getExpiredLeases6/512 728 us 728 us 991
-MemfileLeaseMgrBenchmark/getExpiredLeases6/4096 66537 us 66535 us 11
-MemfileLeaseMgrBenchmark/getExpiredLeases6/32768 4645828 us 4645641 us 1
-MemfileLeaseMgrBenchmark/getExpiredLeases6/65533 23793972 us 23793017 us 1
-@endcode
-
-The results are to be interpreted as follows:
-
-@code
-Benchmark Time CPU Iterations
--------------------------------------------------------------------------------------------------------------
-MemfileLeaseMgrBenchmark/insertLeases4/512 10716 us 10716 us 4
-@endcode
-
-- MemfileLeaseMgrBenchmark - This is a benchmark for memfile lease manager
-- insertLeases4 - this benchmark tests performance of repeated lease insertion for many leases
-- 512 - this is the number of leases that were inserted
-- 10716 us - This is the average time it takes to insert 512 leases. us stands for microseconds, so that's
- a bit over 10 milliseconds.
-- 4 - Benchmark decided to repeat the number of iterations 4 times.
-
-@section benchmarksCode Internal code organization
-
-Benchmarks used isc::dhcp::bench namespace.
-
-Source code for the benchmarks reside in src/lib/dhcpsrv/benchmarks directory,
-although due to similarity with unit tests, some code from testutils is reused.
-Similar to unit-tests for lease managers and host data sources, there are
-generic classes that handle a given manager. See
-@ref isc::dhcp::bench::GenericHostDataSourceBenchmark and
-@ref isc::dhcp::bench::GenericLeaseMgrBenchmark. These classes provide a unified
-implementation for specific benchmarks, like IPv4 lease insertion. There is a
-number of basic operations that are expected to be implemented in each backend.
-Please look for methods that start with bench* prefix in the generic classes.
-
-@section benchmarkControlFlow Explaining control flow in benchmarks
-
-@todo: We should explain how the benchmarks are actually run, what does the state
-parameter passed actually represent, why the setup code needs to be reentrant etc.
-
-@section benchmarkNew Adding new benchmarks
-
-The following is a loose description of all the steps necessary for implementing
-a new benchmark.
-
--# Assuming the benchmark could in principle be run on several backends (all
-benchmarks should, otherwise the major benefit of comparing different backends
-would disappear), there should be a method in the base class (either
-@ref isc::dhcp::bench::GenericHostDataSourceBenchmark or
-@ref isc::dhcp::bench::GenericLeaseMgrBenchmark). See
-@ref isc::dhcp::bench::GenericLeaseMgrBenchmark::benchUpdateLeases4 as an example.
-
--# You need to define a benchmark suing BENCHMARK_DEFINE_F macro. This should be
-done in the backend specific file. For example:
- @code
- // Defines a benchmark that measures IPv4 leases update.
- BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- ReentrantSetUpWithInserts4(state, lease_count);
- benchUpdateLeases4();
- }
- }
- @endcode
-
--# You need to define boundary parameters for the benchmark that was defined
-in step 2. For example:
- @code
- /// A benchmark that measures IPv4 leases update.
- BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases4)
- ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
- @endcode
- This macro defines a range. For this particular example, MIN_LEASE_COUNT is 256
- and MAX_LEASE_COUNT is 65533. Google benchmark will pick several values in that
- range (512, 4096, 32768 and 65533). As a result, the following new benchmarks
- will become available:
- @code
- MemfileLeaseMgrBenchmark/updateLeases4/512
- MemfileLeaseMgrBenchmark/updateLeases4/4096
- MemfileLeaseMgrBenchmark/updateLeases4/32768
- MemfileLeaseMgrBenchmark/updateLeases4/65533
- @endcode
- Those can be run from the command line using --benchmark_filter switch.
-
-*/
+++ /dev/null
-// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
-// 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 <asiolink/io_address.h>
-#include <database/testutils/schema.h>
-#include <dhcp/dhcp6.h>
-#include <dhcp/libdhcp++.h>
-#include <dhcp/option4_addrlst.h>
-#include <dhcp/option6_addrlst.h>
-#include <dhcp/option_int.h>
-#include <dhcp/option_string.h>
-#include <dhcp/option_vendor.h>
-#include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/testutils/host_data_source_utils.h>
-
-using isc::asiolink::IOAddress;
-using isc::dhcp::test::HostDataSourceUtils;
-using std::cerr;
-using std::endl;
-
-namespace isc {
-namespace dhcp {
-namespace bench {
-
-GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark() : hdsptr_() {
- LibDHCP::clearRuntimeOptionDefs();
-}
-
-GenericHostDataSourceBenchmark::~GenericHostDataSourceBenchmark() {
- LibDHCP::clearRuntimeOptionDefs();
- hdsptr_.reset();
-}
-
-void
-GenericHostDataSourceBenchmark::setUp(::benchmark::State& state, size_t const& host_count) {
- state.PauseTiming();
- SetUp(state);
- prepareHosts(host_count);
- state.ResumeTiming();
-}
-
-void
-GenericHostDataSourceBenchmark::setUpWithInserts(::benchmark::State& state,
- size_t const& host_count) {
- state.PauseTiming();
- SetUp(state);
- prepareHosts(host_count);
- insertHosts();
- state.ResumeTiming();
-}
-
-OptionDescriptor
-GenericHostDataSourceBenchmark::createEmptyOption(const Option::Universe& universe,
- const uint16_t option_type,
- const bool persist) const {
- OptionPtr option(new Option(universe, option_type));
- OptionDescriptor desc(option, persist);
- return desc;
-}
-
-OptionDescriptor
-GenericHostDataSourceBenchmark::createVendorOption(const Option::Universe& universe,
- const bool persist,
- const bool formatted,
- const uint32_t vendor_id) const {
- OptionVendorPtr option(new OptionVendor(universe, vendor_id));
-
- std::ostringstream s;
- if (formatted) {
- // Vendor id comprises vendor-id field, for which we need to
- // assign a value in the textual (formatted) format.
- s << vendor_id;
- }
-
- OptionDescriptor desc(option, persist, s.str());
- return desc;
-}
-
-void
-GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host,
- const bool formatted,
- const AddedOptions& added_options) const {
- OptionDefSpaceContainer defs;
-
- if ((added_options == DHCP4_ONLY) || (added_options == DHCP4_AND_DHCP6)) {
- // 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);
- 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");
-
- // Add definitions for DHCPv4 non-standard options.
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1",
- 1, "vendor-encapsulated-options", "uint32")));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-254", 254,
- DHCP4_OPTION_SPACE, "ipv4-address", true)));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "isc", "empty")));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2,
- "isc", "ipv4-address", true)));
- }
-
- 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(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");
-
- // Add definitions for DHCPv6 non-standard options.
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1024", 1024,
- DHCP6_OPTION_SPACE, "ipv6-address", true)));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "isc2", "empty")));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2,
- "isc2", "ipv6-address", true)));
- }
-
- // Register created "runtime" option definitions. They will be used by a
- // host data source to convert option data into the appropriate option
- // classes when the options are retrieved.
- LibDHCP::setRuntimeOptionDefs(defs);
-}
-
-void
-GenericHostDataSourceBenchmark::prepareHosts(size_t const& host_count) {
- if (host_count > 0xfffdu) {
- cerr << "host_count <= 0xfffd or change address xgeneration in "
- "GenericLeaseMgrBenchmark::prepareLeases6()"
- << endl;
- }
- hosts_.clear();
- for (size_t i = 0x0001u; i < 0x0001u + host_count; ++i) {
- std::stringstream ss;
- std::string n_host;
- ss << std::hex << i;
- ss >> n_host;
-
- const std::string prefix = std::string("2001:db8::") + n_host;
- HostPtr host = HostDataSourceUtils::initializeHost6(prefix, Host::IDENT_HWADDR, false);
- addTestOptions(host, false, DHCP4_AND_DHCP6);
- hosts_.push_back(host);
- }
-}
-
-void
-GenericHostDataSourceBenchmark::insertHosts() {
- for (HostPtr host : hosts_) {
- hdsptr_->add(host);
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGetAll() {
- for (HostPtr host : hosts_) {
- std::vector<uint8_t> hwaddr = host->getIdentifier();
- hdsptr_->getAll(host->getIdentifierType(), &hwaddr[0], hwaddr.size());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::getAllv4Resv() {
- for (HostPtr host : hosts_) {
- hdsptr_->getAll4(host->getIPv4Reservation());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGet4IdentifierSubnetId() {
- for (HostPtr host : hosts_) {
- std::vector<uint8_t> hwaddr = host->getIdentifier();
- hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(),
- &hwaddr[0], hwaddr.size());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGet4SubnetIdv4Resrv() {
- for (HostPtr host : hosts_) {
- hdsptr_->get4(host->getIPv4SubnetID(), host->getIPv4Reservation());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGet6IdentifierSubnetId() {
- for (HostPtr host : hosts_) {
- std::vector<uint8_t> hwaddr = host->getIdentifier();
- hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(),
- &hwaddr[0], hwaddr.size());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGet6SubnetIdAddr() {
- for (HostPtr host : hosts_) {
- const IPv6ResrvRange range = host->getIPv6Reservations();
- hdsptr_->get6(host->getIPv6SubnetID(), range.first->second.getPrefix());
- }
-}
-
-void
-GenericHostDataSourceBenchmark::benchGet6Prefix() {
- for (HostPtr host : hosts_) {
- const IPv6ResrvRange range = host->getIPv6Reservations();
- hdsptr_->get6(range.first->second.getPrefix(),
- range.first->second.getPrefixLen());
- }
-}
-
-} // namespace bench
-} // namespace dhcp
-} // namespace isc
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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.
-
-#ifndef GENERIC_HOST_DATA_SOURCE_UNITTEST_H
-#define GENERIC_HOST_DATA_SOURCE_UNITTEST_H
-
-#include <benchmark/benchmark.h>
-
-#include <dhcpsrv/base_host_data_source.h>
-#include <dhcpsrv/host.h>
-
-namespace isc {
-namespace dhcp {
-namespace bench {
-
-/// @brief Base fixture class for benchmarking host backends.
-class GenericHostDataSourceBenchmark : public ::benchmark::Fixture {
-public:
- /// @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_AND_DHCP6 ///< Both DHCPv4 and DHCPv6 options
- };
-
- /// @brief Constructor
- ///
- /// Clears runtime option definitions.
- GenericHostDataSourceBenchmark();
-
- /// @brief Destructor
- ///
- /// Clears runtime option definitions and clears hdsptr_ pointer.
- virtual ~GenericHostDataSourceBenchmark();
-
- /// @brief Creates a generic option with specific parameters.
- ///
- /// @param universe (v4 or v6)
- /// @param option_type code of the option
- /// @param persist whether the option should always be included (yes) or not (no)
- /// @return the option created wrapped in an option descriptor structure
- OptionDescriptor createEmptyOption(const Option::Universe& universe,
- const uint16_t option_type,
- const bool persist) const;
-
- /// @brief Creates an option of specified type and value
- ///
- /// @tparam OptionType Option class to be instantiated
- /// @tparam DataType type of parameter to be passed to OptionType constructor
- /// @param universe (v4 or v6)
- /// @param option_type code of the option
- /// @param persist whether the option should always be included (yes) or not (no)
- /// @param formatted whether the value passed to description should be converted to text
- /// @param value option value
- /// @return the option created wrapped in an option descriptor structure
- template <typename OptionType, typename DataType>
- OptionDescriptor createOption(const Option::Universe& universe,
- const uint16_t option_type,
- const bool persist,
- const bool formatted,
- const DataType& value) const {
- boost::shared_ptr<Option> option(new OptionType(universe, option_type, value));
- std::ostringstream s;
- if (formatted) {
- // Using formatted option value. Convert option value to a
- // textual format.
- s << value;
- }
- OptionDescriptor desc(option, persist, s.str());
- return desc;
- }
-
- /// @brief Creates an option with addresses
- ///
- /// @tparam OptionType specifies a class to be instantiated
- /// @param option_type code of the option
- /// @param persist whether the option should always be included (yes) or not (no)
- /// @param formatted whether the value passed to description should be converted to text
- /// @param address1 first address to be used (optional)
- /// @param address2 second address to be used (optional)
- /// @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 {
-
- std::ostringstream s;
- // First address.
- typename OptionType::AddressContainer addresses;
- if (!address1.empty()) {
- addresses.push_back(asiolink::IOAddress(address1));
- if (formatted) {
- s << address1;
- }
- }
- // Second address.
- if (!address2.empty()) {
- addresses.push_back(asiolink::IOAddress(address2));
- if (formatted) {
- if (s.tellp() != std::streampos(0)) {
- s << ",";
- }
- s << address2;
- }
- }
- // Third address.
- if (!address3.empty()) {
- addresses.push_back(asiolink::IOAddress(address3));
- if (formatted) {
- if (s.tellp() != std::streampos(0)) {
- s << ",";
- }
- s << address3;
- }
- }
-
- boost::shared_ptr<OptionType> option(new OptionType(option_type, addresses));
- OptionDescriptor desc(option, persist, s.str());
- return desc;
- }
-
- /// @brief creates a vendor-option
- ///
- /// @param universe (v4 or v6)
- /// @param persist whether the option should always be included
- /// @param formatted whether the value passed to description should be
- /// converted to text
- /// @param vendor_id 32-unsigned bit enterprise-id
- /// @return the option created wrapped in an option descriptor structure
- OptionDescriptor createVendorOption(const Option::Universe& universe,
- const bool persist,
- const bool formatted,
- const uint32_t vendor_id) const;
-
- /// @brief Adds several v4 and/or v6 options to the host
- ///
- /// @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,
- const AddedOptions& added_options) const;
-
- /// @brief Sets up timers, creates and inserts hosts.
- ///
- /// @param state reference to the state of the benchmark
- /// @param host_count number of hosts to be created
- void setUp(::benchmark::State& state, size_t const& host_count);
-
- /// @brief Sets up the benchmark with specified number of hosts
- ///
- /// @param state reference to the state of the benchmark
- /// @param host_count number of hosts to be created
- void setUpWithInserts(::benchmark::State& state, size_t const& host_count);
-
- /// @brief Creates specified number of hosts and stores them in hosts_
- ///
- /// @param host_count number of hosts to be created
- void prepareHosts(size_t const& host_count);
-
- /// @brief Inserts all hosts stored in hosts_ into the benchmarked host backend
- void insertHosts();
-
- /// @brief Essential steps required to benchmark the
- /// getAll(identifier-type, identifier) call.
- void benchGetAll();
-
- /// @brief Essential steps required to benchmark host reservation retrieval
- /// using getAll(ipv4-reservation) call.
- void getAllv4Resv();
-
- /// @brief Essential steps requires to benchmark host reservation retrieval
- /// using getAll(identifier-type, identifier, subnet-id) call.
- void benchGet4IdentifierSubnetId();
-
- /// @brief Essential steps requires to benchmark host reservation retrieval
- /// using getAll(v4-reservation) call.
- void benchGet4SubnetIdv4Resrv();
-
- /// @brief Essential steps requires to benchmark host reservation retrieval
- /// using get6(identifier-type, identifier, subnet-id) call.
- void benchGet6IdentifierSubnetId();
-
- /// @brief Essential steps requires to benchmark host reservation retrieval
- /// using get6(ip-addr, subnet-id) call.
- void benchGet6SubnetIdAddr();
-
- /// @brief Essential steps requires to benchmark host reservation retrieval
- /// using get6(prefix, len) call.
- void benchGet6Prefix();
-
- /// Pointer to the host backend being benchmarked
- HostDataSourcePtr hdsptr_;
-
- /// Store hosts being used during benchmark.
- HostCollection hosts_;
-};
-
-} // namespace bench
-} // namespace dhcp
-} // namespace isc
-
-#endif
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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 <chrono>
-#include <iomanip>
-#include <iostream>
-#include <string>
-#include <vector>
-
-using namespace isc::asiolink;
-using namespace std;
-using namespace std::chrono;
-
-namespace isc {
-namespace dhcp {
-namespace bench {
-
-GenericLeaseMgrBenchmark::GenericLeaseMgrBenchmark() : lmptr_(NULL) {
-}
-
-GenericLeaseMgrBenchmark::~GenericLeaseMgrBenchmark() {
-}
-
-void
-GenericLeaseMgrBenchmark::setUp4(::benchmark::State& state, size_t const& lease_count) {
- state.PauseTiming();
- SetUp(state);
- prepareLeases4(lease_count);
- state.ResumeTiming();
-}
-
-void
-GenericLeaseMgrBenchmark::setUpWithInserts4(::benchmark::State& state,
- size_t const& lease_count) {
- state.PauseTiming();
- SetUp(state);
- prepareLeases4(lease_count);
- benchInsertLeases4();
- state.ResumeTiming();
-}
-
-void
-GenericLeaseMgrBenchmark::setUp6(::benchmark::State& state, size_t const& lease_count) {
- state.PauseTiming();
- SetUp(state);
- prepareLeases6(lease_count);
- state.ResumeTiming();
-}
-
-void
-GenericLeaseMgrBenchmark::setUpWithInserts6(::benchmark::State& state,
- size_t const& lease_count) {
- state.PauseTiming();
- SetUp(state);
- prepareLeases6(lease_count);
- benchInsertLeases6();
- state.ResumeTiming();
-}
-
-void
-GenericLeaseMgrBenchmark::prepareLeases4(size_t const& lease_count) {
- leases4_.clear();
- for (size_t i = 0x0001u; i < 0x0001u + lease_count; ++i) {
- Lease4Ptr lease(new Lease4());
- lease->addr_ = IOAddress(i);
- lease->hwaddr_.reset(new HWAddr(vector<uint8_t>(6, i), HTYPE_ETHER));
- lease->client_id_ = ClientIdPtr(new ClientId(vector<uint8_t>(8, 2 * i)));
- lease->valid_lft_ = i;
- lease->cltt_ = i;
- lease->subnet_id_ = i;
- lease->fqdn_rev_ = (i % 2) ? true : false;
- lease->fqdn_fwd_ = (i % 2) ? true : false;
- lease->hostname_ = to_string(i) + ".host.com";
- leases4_.push_back(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchInsertLeases4() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->addLease(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchUpdateLeases4() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->updateLease4(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease4_address() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->getLease4(lease->addr_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease4_hwaddr() {
- for (Lease4Ptr const& lease : leases4_) {
- const Lease4Collection collection = lmptr_->getLease4(*lease->hwaddr_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease4_hwaddr_subnetid() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->getLease4(*lease->hwaddr_, lease->subnet_id_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease4_clientid() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->getLease4(*lease->client_id_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease4_clientid_subnetid() {
- for (Lease4Ptr const& lease : leases4_) {
- lmptr_->getLease4(*lease->client_id_, lease->subnet_id_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetExpiredLeases4() {
- Lease4Collection expired_leases;
- lmptr_->getExpiredLeases4(expired_leases, leases4_.size());
-}
-
-void
-GenericLeaseMgrBenchmark::prepareLeases6(size_t const& lease_count) {
- if (lease_count > 0xfffdu) {
- cerr << "lease_count <= 0xfffd or change address generation in "
- "GenericLeaseMgrBenchmark::prepareLeases6()"
- << endl;
- }
- leases6_.clear();
- for (size_t i = 0x0001u; i < 0x0001u + lease_count; ++i) {
- stringstream ss;
- string n_lease;
- ss << std::hex << i;
- ss >> n_lease;
- const string prefix = string("2001:db8::") + n_lease;
- Lease6Ptr lease(new Lease6());
- lease->addr_ = IOAddress(prefix);
- lease->type_ = static_cast<Lease::Type>(i % 3); // NA, TA or PD
- lease->prefixlen_ = i % 128;
- lease->iaid_ = i;
- lease->duid_ = DuidPtr(new DUID(vector<uint8_t>(8, i)));
- lease->preferred_lft_ = i;
- lease->valid_lft_ = i;
- lease->cltt_ = i;
- lease->subnet_id_ = i;
- lease->fqdn_fwd_ = (i % 2 == 0) ? true : false;
- lease->fqdn_rev_ = (i % 2 == 0) ? true : false;
- lease->hostname_ = n_lease + ".host.com";
- leases6_.push_back(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchInsertLeases6() {
- for (Lease6Ptr const& lease : leases6_) {
- lmptr_->addLease(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchUpdateLeases6() {
- for (Lease6Ptr const& lease : leases6_) {
- lmptr_->updateLease6(lease);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease6_type_address() {
- for (Lease6Ptr const& lease : leases6_) {
- lmptr_->getLease6(lease->type_, lease->addr_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid() {
- for (Lease6Ptr const& lease : leases6_) {
- lmptr_->getLeases6(lease->type_, *lease->duid_, lease->iaid_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid_subnetid() {
- for (Lease6Ptr const& lease : leases6_) {
- lmptr_->getLease6(lease->type_, *lease->duid_, lease->iaid_,
- lease->subnet_id_);
- }
-}
-
-void
-GenericLeaseMgrBenchmark::benchGetExpiredLeases6() {
- Lease6Collection expired_leases;
- lmptr_->getExpiredLeases6(expired_leases, leases6_.size());
-}
-
-/// @todo: Calls that aren't measured:
-/// - deleteLease(const Lease4Ptr& lease);
-/// - deleteLease(const Lease6Ptr& lease);
-/// - deleteExpiredReclaimedLeases6(const uint32_t secs);
-
-} // namespace bench
-} // namespace dhcp
-} // namespace isc
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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.
-
-#ifndef GENERIC_LEASE_MGR_BENCHMARK_H
-#define GENERIC_LEASE_MGR_BENCHMARK_H
-
-#include <benchmark/benchmark.h>
-
-#include <dhcpsrv/lease_mgr.h>
-
-namespace isc {
-namespace dhcp {
-namespace bench {
-
-/// @brief A base class for a fixture for specific lease manager benchmarks
-class GenericLeaseMgrBenchmark : public benchmark::Fixture {
-public:
- /// Specifies the IP protocol family to be bested.
- enum Universe { V4, V6 };
-
- /// Constructor
- GenericLeaseMgrBenchmark();
-
- /// Virtual destructor
- virtual ~GenericLeaseMgrBenchmark();
-
- /// @brief set up code for initializing IPv4 version of a benchmark
- ///
- /// @param state state to be passed to SetUp
- /// @param lease_count number of leases to be tested
- void setUp4(::benchmark::State& state, size_t const& lease_count);
-
- /// @brief set up code (with lease preinsertion) for initializing IPv4
- /// version of a benchmark.
- ///
- /// @param state state to be passed to SetUp
- /// @param lease_count number of leases to be tested
- void setUpWithInserts4(::benchmark::State& state, size_t const& lease_count);
-
- /// @brief set up code for initializing IPv6 version of a benchmark
- ///
- /// @param state state to be passed to SetUp
- /// @param lease_count number of leases to be tested
- void setUp6(::benchmark::State& state, size_t const& lease_count);
-
- /// @brief set up code (with lease preinsertion) for initializing IPv6
- /// version of a benchmark.
- ///
- /// @param state state to be passed to SetUp
- /// @param lease_count number of leases to be tested
- void setUpWithInserts6(::benchmark::State& state, size_t const& lease_count);
-
- /// @brief Prepares specified number of IPv4 leases
- ///
- /// The leases are stored in leases4_ container.
- /// @param lease_count specifies the number of leases to be created.
- void prepareLeases4(size_t const& lease_count);
-
- /// @brief This step inserts all IPv4 leases stored in lease4_ into the LeaseMgr.
- void benchInsertLeases4();
-
- /// @brief This step updates all IPv4 leases stored in lease4_ in the LeaseMgr.
- void benchUpdateLeases4();
-
- /// @brief This step retrieves IPv4 leases by IP address.
- void benchGetLease4_address();
-
- /// @brief This step retrieves IPv4 leases by hardware address.
- void benchGetLease4_hwaddr();
-
- /// @brief This step retrieves IPv4 leases by (hwaddr, subnet-id) tuple.
- void benchGetLease4_hwaddr_subnetid();
-
- /// @brief This step retrieves IPv4 leases by client-id.
- void benchGetLease4_clientid();
-
- /// @brief This step retrieves IPv4 leases by (client-id, subnet-id) tuple.
- void benchGetLease4_clientid_subnetid();
-
- /// @brief This step retrieves all expired IPv4 leases.
- void benchGetExpiredLeases4();
-
- /// @brief Prepares specified number of IPv6 leases
- ///
- /// The leases are stored in leases6_ container.
- /// @param lease_count specifies the number of leases to be created.
- void prepareLeases6(size_t const& lease_count);
-
- /// @brief This step inserts all IPv6 leases stored in lease6_ into the LeaseMgr.
- void benchInsertLeases6();
-
- /// @brief This step updates all IPv6 leases stored in lease6_ in the LeaseMgr.
- void benchUpdateLeases6();
-
- /// @brief This step retrieves IPv6 leases by IP address.
- void benchGetLease6_type_address();
-
- /// @brief This step retrieves IPv6 leases by (type, duid, iaid) tuple.
- void benchGetLease6_type_duid_iaid();
-
- /// @brief This step retrieves IPv6 leases by (type, duid, iaid, subnet-id) tuple.
- void benchGetLease6_type_duid_iaid_subnetid();
-
- /// @brief This step retrieves all expired IPv6 leases.
- void benchGetExpiredLeases6();
-
- /// Pointer to the lease manager being under evaluation.
- LeaseMgr* lmptr_;
-
- /// List of IPv4 leases (useful during benchmarks)
- Lease4Collection leases4_;
-
- /// List of IPv6 leases (useful during benchmarks)
- Lease6Collection leases6_;
-};
-
-} // namespace bench
-} // namespace dhcp
-} // namespace isc
-
-#endif
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#include <config.h>
-
-#include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
-#include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/memfile_lease_mgr.h>
-#include <dhcpsrv/testutils/lease_file_io.h>
-
-using namespace isc::dhcp;
-using namespace isc::dhcp::bench;
-using namespace isc::dhcp::test;
-using namespace std;
-
-namespace {
-
-/// @brief This is a fixture class used for benchmarking Memfile lease backend
-class MemfileLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
-public:
- /// @brief Constructor
- ///
- /// Sets the files used for writing lease files.
- MemfileLeaseMgrBenchmark() : io4_(""), io6_("") {
- }
-
- /// @brief Setup routine.
- ///
- /// Removes any files left over from earlier test, destroys any existing
- /// lease manager, and then starts a new memfile lease manager.
- /// The state parameter is ignored.
- void SetUp(::benchmark::State const&) override {
-
- io4_ = LeaseFileIO(getLeaseFilePath("leasefile4_0.csv"));
- io6_ = LeaseFileIO(getLeaseFilePath("leasefile6_0.csv"));
-
- // Remove lease files and products of Lease File Cleanup.
- removeFiles(getLeaseFilePath("leasefile4_0.csv"));
- removeFiles(getLeaseFilePath("leasefile6_0.csv"));
-
- try {
- LeaseMgrFactory::destroy();
- startBackend(V4);
- } catch (...) {
- std::cerr << "ERROR: unable to start memfile backend." << std::endl;
- throw;
- }
- 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).
- void startBackend(Universe u) {
- try {
- LeaseMgrFactory::create(getConfigString(u));
- } catch (...) {
- std::cerr << "*** ERROR: unable to create instance of the Memfile "
- << "lease database backend." << std::endl;
- throw;
- }
- lmptr_ = &(LeaseMgrFactory::instance());
- }
-
- /// @brief Returns the configuration string for the backend.
- ///
- /// This string configures the @c LeaseMgrFactory to create the memfile
- /// backend and use leasefile4_0.csv and leasefile6_0.csv files as
- /// storage for leases.
- ///
- /// @param no_universe Indicates whether universe parameter should be
- /// included (false), or not (true).
- ///
- /// @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")
- << " lfc-interval=0";
- return (s.str());
- }
-
- /// @brief Return path to the lease file used by unit tests.
- ///
- /// @param filename Name of the lease file appended to the path to the
- /// directory where test data is held.
- ///
- /// @return Full path to the lease file.
- static std::string getLeaseFilePath(const std::string& filename) {
- std::ostringstream s;
- s << TEST_DATA_BUILDDIR << "/" << filename;
- return (s.str());
- }
-
- /// @brief Remove files being products of Lease File Cleanup.
- ///
- /// @param base_name Path to the lease file name. This file is removed
- /// and all files which names are created from this name (having specific
- /// suffixes used by Lease File Cleanup mechanism).
- void removeFiles(const std::string& base_name) const {
- // Generate suffixes and append them to the base name. The
- // resulting file names are the ones that may exist as a
- // result of LFC.
- for (int i = static_cast<int>(Memfile_LeaseMgr::FILE_CURRENT);
- i <= static_cast<int>(Memfile_LeaseMgr::FILE_FINISH); ++i) {
- Memfile_LeaseMgr::LFCFileType type = static_cast<Memfile_LeaseMgr::LFCFileType>(i);
- LeaseFileIO io(Memfile_LeaseMgr::appendSuffix(base_name, type));
- io.removeFile();
- }
- }
-
- /// @brief Cleans up after the test.
- ///
- /// Rolls back any uncommitted operation (really a no-op for memfile as it
- /// does not support transactions), then destroys the lease manager
- /// and finally cleans up the files.
- void TearDown(::benchmark::State const&) override {
- try {
- lmptr_->rollback();
- } catch (...) {
- std::cerr << "WARNING: rollback has failed. This is surprising as "
- << "memfile doesn't support rollback." << std::endl;
- }
-
- LeaseMgrFactory::destroy();
-
- // Remove lease files and products of Lease File Cleanup.
- removeFiles(getLeaseFilePath("leasefile4_0.csv"));
- 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_;
-
- /// @brief Object providing access to v6 lease IO.
- LeaseFileIO io6_;
-};
-
-// Defines a benchmark that measures IPv4 leases insertion.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp4(state, lease_count);
- benchInsertLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases update.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchUpdateLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by address.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_address();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address
-// and subnet-id.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr_subnetid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id and
-// subnet-id.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv4 leases.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetExpiredLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases insertion.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp6(state, lease_count);
- benchInsertLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases update.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchUpdateLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type and address.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_address();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type, duid and iaid.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid();
- }
-}
-
-// 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) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv6 leases.
-BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetExpiredLeases6();
- }
-}
-
-/// 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);
-
-/// A benchmark that measures IPv4 leases update.
-BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases4)
- ->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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// A benchmark that measures expired IPv4 leases retrieval.
-BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getExpiredLeases4)
- ->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);
-
-/// A benchmark that measures IPv6 leases update.
-BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, 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(MemfileLeaseMgrBenchmark, 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(MemfileLeaseMgrBenchmark, 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(MemfileLeaseMgrBenchmark, 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(MemfileLeaseMgrBenchmark, getExpiredLeases6)
- ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
-
-} // namespace
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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 <mysql/testutils/mysql_schema.h>
-
-#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
-#include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/host_mgr.h>
-
-#include <iostream>
-
-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:
- /// @brief Setup routine.
- ///
- /// It cleans up schema and recreates tables, then instantiates HostMgr
- void SetUp(::benchmark::State const&) override {
- // Ensure we have the proper schema with no transient data.
- createMySQLSchema();
- try {
- HostMgr::create();
- HostMgr::addBackend(validMySQLConnectionString());
- } catch (...) {
- cerr << "ERROR: unable to open database" << endl;
- throw;
- }
- hdsptr_ = HostMgr::instance().getHostDataSource();
- }
-
- 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 {
- hdsptr_->rollback();
- } catch (...) {
- cerr << "WARNING: rollback has failed, this is expected if database"
- " is opened in read-only mode, continuing..."
- << endl;
- }
- 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
-/// hosts insertion.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUp(state, host_count);
- insertHosts();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll4(hw-addr, duid) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAll)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGetAll();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll(v4-reservation) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- getAllv4Resv();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet4IdentifierSubnetId();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(subnet-id, v4-reservation) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet4SubnetIdv4Resrv();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6IdentifierSubnetId();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, ip-address) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6SubnetIdAddr();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(ip-prefix, prefix-len) call.
-BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6Prefix();
- }
-}
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts insertion.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, insertHosts)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll4(hw-addr, duid) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAll)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll(v4-reservation) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllv4Resv)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(subnet-id, v4-reservation) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, ip-address) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(ip-prefix, prefix-len) call.
-BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6Prefix)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-} // namespace
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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 <mysql/testutils/mysql_schema.h>
-
-#include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
-#include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/lease_mgr_factory.h>
-
-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:
- /// @brief Setup routine.
- ///
- /// It cleans up schema and recreates tables, then instantiates LeaseMgr
- void SetUp(::benchmark::State const&) override {
- // Ensure we have the proper schema with no transient data.
- createMySQLSchema();
- try {
- LeaseMgrFactory::destroy();
- LeaseMgrFactory::create(validMySQLConnectionString());
- } catch (...) {
- cerr << "ERROR: unable to open database" << endl;
- throw;
- }
- 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 {
- lmptr_->rollback();
- } catch (...) {
- cerr << "WARNING: rollback has failed, this is expected if database"
- " is opened in read-only mode, continuing..."
- << endl;
- }
- LeaseMgrFactory::destroy();
- // 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.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp4(state, lease_count);
- benchInsertLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases update.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchUpdateLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by address.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_address();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address
-// and subnet-id.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr_subnetid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id and
-// subnet-id.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv4 leases.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetExpiredLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases insertion.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp6(state, lease_count);
- benchInsertLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases update.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchUpdateLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type and address.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_address();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type, duid and iaid.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid();
- }
-}
-
-// 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) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv6 leases.
-BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetExpiredLeases6();
- }
-}
-
-/// 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);
-
-/// A benchmark that measures IPv4 leases update.
-BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, updateLeases4)
- ->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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// A benchmark that measures expired IPv4 leases retrieval.
-BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, getExpiredLeases4)
- ->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);
-
-/// A benchmark that measures IPv6 leases update.
-BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, 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(MySqlLeaseMgrBenchmark, 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(MySqlLeaseMgrBenchmark, 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(MySqlLeaseMgrBenchmark, 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(MySqlLeaseMgrBenchmark, getExpiredLeases6)
- ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
-
-} // namespace
+++ /dev/null
-// Copyright (C) 2018-2019,2021 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef BENCHMARKS_PARAMETERS_H
-#define BENCHMARKS_PARAMETERS_H
-
-#include <benchmark/benchmark.h>
-
-namespace isc {
-namespace dhcp {
-namespace bench {
-
-/// @defgroup benchmark_params Benchmark parameters that define boundary values
-/// for benchmarks.
-///
-/// The range is defined as 512..65533. Google benchmark will pick a few specific
-/// values: 512, 4096, 32768, 65533.
-
-/// @{
-
-/// @brief A minimum number of leases used in a benchmark
-constexpr size_t MIN_LEASE_COUNT = 512;
-/// @brief A maximum number of leases used in a benchmark
-constexpr size_t MAX_LEASE_COUNT = 0xfffd;
-
-/// @brief A minimum number of leases used in a benchmark
-constexpr size_t MIN_HOST_COUNT = 512;
-/// @brief A maximum number of leases used in a benchmark
-constexpr size_t MAX_HOST_COUNT = 0xfffd;
-
-/// @brief A time unit used - all results to be expressed in us (microseconds)
-constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond;
-
-/// @}
-
-} // namespace bench
-} // namespace dhcp
-} // namespace isc
-
-#endif
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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 <pgsql/testutils/pgsql_schema.h>
-
-#include <dhcpsrv/benchmarks/generic_host_data_source_benchmark.h>
-#include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/host_data_source_factory.h>
-#include <dhcpsrv/host_mgr.h>
-
-#include <iostream>
-
-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 host backend
-class PgSqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark {
-public:
- /// @brief Setup routine.
- ///
- /// It cleans up schema and recreates tables, then instantiates HostMgr
- void SetUp(::benchmark::State const&) override {
- // Ensure we have the proper schema with no transient data.
- createPgSQLSchema();
- try {
- HostMgr::create();
- HostMgr::addBackend(validPgSQLConnectionString());
- } catch (...) {
- cerr << "ERROR: unable to open database" << endl;
- throw;
- }
- hdsptr_ = HostMgr::instance().getHostDataSource();
- }
-
- 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 {
- hdsptr_->rollback();
- } catch (...) {
- cerr << "WARNING: rollback has failed, this is expected if database"
- " is opened in read-only mode, continuing..."
- << endl;
- }
- 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
-/// hosts insertion.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUp(state, host_count);
- insertHosts();
- }
-}
-
-/// 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) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGetAll();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by getAll(v4-reservation) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- getAllv4Resv();
- }
-}
-
-/// 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) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet4IdentifierSubnetId();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get4(subnet-id, v4-reservation) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet4SubnetIdv4Resrv();
- }
-}
-
-/// 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) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6IdentifierSubnetId();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(subnet-id, ip-address) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6SubnetIdAddr();
- }
-}
-
-/// Defines steps necessary for conducting a benchmark that measures
-/// hosts retrieval by get6(ip-prefix, prefix-len) call.
-BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) {
- const size_t host_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts(state, host_count);
- benchGet6Prefix();
- }
-}
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts insertion.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll4(hw-addr, duid) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by getAll(v4-reservation) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get4(subnet-id, v4-reservation) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(subnet-id, ip-address) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-/// Defines parameters necessary for running a benchmark that measures
-/// hosts retrieval by get6(ip-prefix, prefix-len) call.
-BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix)
- ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT);
-
-} // namespace
+++ /dev/null
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
-// 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 <pgsql/testutils/pgsql_schema.h>
-
-#include <dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h>
-#include <dhcpsrv/benchmarks/parameters.h>
-#include <dhcpsrv/lease_mgr_factory.h>
-
-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:
- /// @brief Setup routine.
- ///
- /// It cleans up schema and recreates tables, then instantiates LeaseMgr
- void SetUp(::benchmark::State const&) override {
- // Ensure we have the proper schema with no transient data.
- createPgSQLSchema();
- try {
- LeaseMgrFactory::destroy();
- LeaseMgrFactory::create(validPgSQLConnectionString());
- } catch (...) {
- cerr << "ERROR: unable to open database" << endl;
- throw;
- }
- 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 {
- lmptr_->rollback();
- } catch (...) {
- cerr << "WARNING: rollback has failed, this is expected if database"
- " is opened in read-only mode, continuing..."
- << endl;
- }
- LeaseMgrFactory::destroy();
- // 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.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp4(state, lease_count);
- benchInsertLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases update.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchUpdateLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by address.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_address();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by hardware address
-// and subnet-id.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_hwaddr_subnetid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid();
- }
-}
-
-// Defines a benchmark that measures IPv4 leases retrieval by client-id and
-// subnet-id.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetLease4_clientid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv4 leases.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts4(state, lease_count);
- benchGetExpiredLeases4();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases insertion.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUp6(state, lease_count);
- benchInsertLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases update.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchUpdateLeases6();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type and address.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_address();
- }
-}
-
-// Defines a benchmark that measures IPv6 leases retrieval by type, duid and iaid.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid();
- }
-}
-
-// 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) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetLease6_type_duid_iaid_subnetid();
- }
-}
-
-// Defines a benchmark that measures retrieval of expired IPv6 leases.
-BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
- const size_t lease_count = state.range(0);
- while (state.KeepRunning()) {
- setUpWithInserts6(state, lease_count);
- benchGetExpiredLeases6();
- }
-}
-
-/// 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);
-
-/// A benchmark that measures IPv4 leases update.
-BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, updateLeases4)
- ->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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// 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);
-
-/// A benchmark that measures expired IPv4 leases retrieval.
-BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getExpiredLeases4)
- ->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);
-
-/// A benchmark that measures IPv6 leases update.
-BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, 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(PgSqlLeaseMgrBenchmark, 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(PgSqlLeaseMgrBenchmark, 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(PgSqlLeaseMgrBenchmark, 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(PgSqlLeaseMgrBenchmark, getExpiredLeases6)
- ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
-
-} // namespace
+++ /dev/null
-// 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 <benchmark/benchmark.h>
-#include <log/logger_support.h>
-
-/// @brief A simple class that initializes logging.
-class Initializer {
-public:
- Initializer() {
- isc::log::initLogger();
- }
-};
-
-Initializer initializer;
-
-BENCHMARK_MAIN();