From: Razvan Becheriu Date: Fri, 16 Feb 2018 09:51:51 +0000 (+0200) Subject: minor changes - updated comments for google benchmarks X-Git-Tag: kea5574_base~10^2~1^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=275599fcbd95ef90676749e172878731bd6cae1f;p=thirdparty%2Fkea.git minor changes - updated comments for google benchmarks --- diff --git a/configure.ac b/configure.ac index eaf735b84d..3e94d69f45 100644 --- a/configure.ac +++ b/configure.ac @@ -133,15 +133,15 @@ AX_ISC_CPP11 # Check for std::is_base_of support AC_MSG_CHECKING([for std::is_base_of]) AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [#include - class A {}; - class B : A {};] - [static_assert(std::is_base_of::value, "");])], - [AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_IS_BASE_OF], [1], - [Define to 1 if std::is_base_of is available])], - [AC_MSG_RESULT(no)]) + [AC_LANG_PROGRAM( + [#include + class A {}; + class B : A {};] + [static_assert(std::is_base_of::value, "");])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_IS_BASE_OF], [1], + [Define to 1 if std::is_base_of is available])], + [AC_MSG_RESULT(no)]) dnl Determine if we are using GNU sed GNU_SED=no @@ -408,7 +408,6 @@ case "$host" in ;; esac - # Kea-shell is written in python. It can work with python 2.7 or any 3.x. # It may likely work with earlier versions, but 2.7 was the oldest one we tested # it with. We require python only if kea-shell was enabled. It is disabled @@ -906,9 +905,9 @@ if test "x$enable_gtest" = "xyes" ; then AC_MSG_ERROR([no gtest source but it was selected]) fi else - if test ! -d $GTEST_SOURCE/src -a -d $GTEST_SOURCE/googletest; then - GTEST_SOURCE=$GTEST_SOURCE/googletest - fi + if test ! -d $GTEST_SOURCE/src -a -d $GTEST_SOURCE/googletest; then + GTEST_SOURCE=$GTEST_SOURCE/googletest + fi AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc] [$GTEST_SOURCE/src/gtest_main.cc], [have_gtest_source=yes], @@ -918,7 +917,7 @@ if test "x$enable_gtest" = "xyes" ; then GTEST_LDADD="\$(top_builddir)/ext/gtest/libgtest.a" DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest-source=$GTEST_SOURCE" GTEST_INCLUDES="-I$GTEST_SOURCE -I$GTEST_SOURCE/include" - GTEST_VERSION="`basename $GTEST_SOURCE`" + GTEST_VERSION="`basename $GTEST_SOURCE`" fi if test "$gtest_path" != "no" ; then @@ -977,6 +976,7 @@ AC_SUBST(GTEST_SOURCE) # # Check availability of benchmark. # +BENCHMARK_CPPFLAGS= BENCHMARK_LDFLAGS= BENCHMARK_LDADD= DISTCHECK_BENCHMARK_CONFIGURE_FLAG= @@ -1012,7 +1012,8 @@ if test "x$enable_benchmark" = "xyes" ; then [AC_MSG_ERROR([no benchmark source at $BENCHMARK_SOURCE])]) fi have_benchmark_source=yes - BENCHMARK_LDADD="\$(top_builddir)/ext/benchmark/libbenchmark.a" + 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 \ @@ -1024,42 +1025,24 @@ if test "x$enable_benchmark" = "xyes" ; then if test "$benchmark_path" != "no" ; then if test "$benchmark_path" != "yes"; then BENCHMARK_PATHS=$benchmark_path - if test -x "${benchmark_path}/bin/benchmark-config" ; then - BENCHMARK_CONFIG="${benchmark_path}/bin/benchmark-config" - fi - else - AC_PATH_PROG([BENCHMARK_CONFIG], [benchmark-config]) fi - if test -x "${BENCHMARK_CONFIG}" ; then : - # using cppflags instead of cxxflags - BENCHMARK_INCLUDES=$(${BENCHMARK_CONFIG} --cppflags) - BENCHMARK_LDFLAGS=$(${BENCHMARK_CONFIG} --ldflags) - BENCHMARK_LDADD=$(${BENCHMARK_CONFIG} --libs) - BENCHMARK_VERSION=$(${BENCHMARK_CONFIG} --version) - BENCHMARK_FOUND="true" - else - AC_MSG_WARN([Unable to locate Google Benchmark benchmark-config.]) - if test -z "${BENCHMARK_PATHS}" ; then - BENCHMARK_PATHS="/usr /usr/local" - fi - BENCHMARK_FOUND="false" + if test -z "${BENCHMARK_PATHS}" ; then + BENCHMARK_PATHS="/usr /usr/local" fi - if test "${BENCHMARK_FOUND}" != "true"; then - BENCHMARK_FOUND="false" - for dir in ${BENCHMARK_PATHS}; do - if test -f "$dir/include/benchmark/benchmark.h"; then - if ! test -f "$dir/lib/libbenchmark.a"; then - AC_MSG_WARN([Found Google Benchmark include but not the library in $dir.]) - continue - fi - BENCHMARK_INCLUDES="-I$dir/include" - BENCHMARK_LDFLAGS="-L$dir/lib" - BENCHMARK_LDADD="$dir/lib/libbenchmark.a " - BENCHMARK_FOUND="true" - break + 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 - done - 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 @@ -1069,6 +1052,7 @@ fi AM_CONDITIONAL(HAVE_BENCHMARK, test $enable_benchmark != "no") AM_CONDITIONAL(HAVE_BENCHMARK_SOURCE, test "X$have_benchmark_source" = "Xyes") AC_SUBST(DISTCHECK_BENCHMARK_CONFIGURE_FLAG) +AC_SUBST(BENCHMARK_CPPFLAGS) AC_SUBST(BENCHMARK_INCLUDES) AC_SUBST(BENCHMARK_LDFLAGS) AC_SUBST(BENCHMARK_LDADD) @@ -1083,15 +1067,15 @@ if test $enable_gtest != "no"; then CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [#include - #include - void foo() { - boost::shared_ptr bar; - ASSERT_TRUE(bar); + [#include + #include + void foo() { + boost::shared_ptr bar; + ASSERT_TRUE(bar); }], - [return 0;])], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR([XXX_TRUE() Google Test macros won't compile; the most likely reason is that a later version of Google Test is required])]) + [return 0;])], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([XXX_TRUE() Google Test macros won't compile; the most likely reason is that a later version of Google Test is required])]) CPPFLAGS=$CPPFLAGS_SAVED fi @@ -1102,21 +1086,21 @@ if test $enable_gtest != "no"; then CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [#include - #include - #include - #include - std::string nodiff(std::string text) { - std::vector lines; - boost::split(lines, text, boost::is_any_of("\n")); - using namespace testing::internal; - return (edit_distance::CreateUnifiedDiff(lines, lines)); - }], - [return 0;])], - [AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_CREATE_UNIFIED_DIFF], [1], - [Define to 1 if gtest defines edit_distance::CreateUnifiedDiff])], - [AC_MSG_RESULT(no)]) + [#include + #include + #include + #include + std::string nodiff(std::string text) { + std::vector lines; + boost::split(lines, text, boost::is_any_of("\n")); + using namespace testing::internal; + return (edit_distance::CreateUnifiedDiff(lines, lines)); + }], + [return 0;])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_CREATE_UNIFIED_DIFF], [1], + [Define to 1 if gtest defines edit_distance::CreateUnifiedDiff])], + [AC_MSG_RESULT(no)]) CPPFLAGS=$CPPFLAGS_SAVED fi @@ -1152,7 +1136,7 @@ AC_CHECK_FUNCS([pselect]) # code will be updated by the time we really need it. AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no) if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then - CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_DEV_POLL=1" + CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_DEV_POLL=1" fi # @@ -1617,9 +1601,9 @@ if test "$CQL_CPPFLAGS" != "" ; then cat >> config.report << END Cassandra CQL: - CQL_VERSION: ${CQL_VERSION} - CQL_CPPFLAGS: ${CQL_CPPFLAGS} - CQL_LIBS: ${CQL_LIBS} + CQL_VERSION: ${CQL_VERSION} + CQL_CPPFLAGS: ${CQL_CPPFLAGS} + CQL_LIBS: ${CQL_LIBS} END else cat >> config.report << END @@ -1651,6 +1635,7 @@ 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} diff --git a/src/lib/dhcpsrv/benchmarks/Makefile.am b/src/lib/dhcpsrv/benchmarks/Makefile.am index 7f2f05c6cb..c99b884fac 100644 --- a/src/lib/dhcpsrv/benchmarks/Makefile.am +++ b/src/lib/dhcpsrv/benchmarks/Makefile.am @@ -40,7 +40,7 @@ run_benchmarks_SOURCES += cql_lease_mgr_benchmark.cc run_benchmarks_SOURCES += cql_host_data_source_benchmark.cc endif -run_benchmarks_CPPFLAGS = $(AM_CPPFLAGS) $(BENCHMARK_INCLUDES) -Wno-error=overloaded-virtual +run_benchmarks_CPPFLAGS = $(AM_CPPFLAGS) $(BENCHMARK_INCLUDES) $(BENCHMARK_CPPFLAGS) -Wno-error=overloaded-virtual if HAVE_MYSQL run_benchmarks_CPPFLAGS += $(MYSQL_CPPFLAGS) @@ -74,7 +74,6 @@ run_benchmarks_LDADD = $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest run_benchmarks_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la run_benchmarks_LDADD += $(BENCHMARK_LDADD) run_benchmarks_LDADD += $(LOG4CPLUS_LIBS) run_benchmarks_LDADD += $(CRYPTO_LIBS) diff --git a/src/lib/dhcpsrv/benchmarks/benchmarks.dox b/src/lib/dhcpsrv/benchmarks/benchmarks.dox index cf0ffe41e4..183e3ddde4 100644 --- a/src/lib/dhcpsrv/benchmarks/benchmarks.dox +++ b/src/lib/dhcpsrv/benchmarks/benchmarks.dox @@ -22,15 +22,14 @@ $ make 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-dhcp-mysql, ---with-dhcp-pgsql --with-cql 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 or keyspace is created. The setup is the same as for -running unit-tests. DB name or keyspace 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. +enable the backends you want to measure (See --with-mysql, --with-pgsql, +--with-cql 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 or keyspace +is created. The setup is the same as for running unit-tests. +DB name or keyspace 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: diff --git a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc index ad3dd6286a..f0223012be 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc @@ -21,7 +21,6 @@ #include #include #include - #include using namespace isc::dhcp::bench; @@ -31,11 +30,13 @@ using namespace std; namespace { -/// @brief Fixture class for benchmarking Cassandra host backend +/// @brief This is a fixture class used for benchmarking Cassandra host backend class CqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark { public: - /// @brief Before benchmark setup. + /// @brief Setup routine. + /// + /// It cleans up schema and recreates tables, then instantiates HostMgr void SetUp(::benchmark::State const&) override { destroyCqlSchema(false, true); createCqlSchema(false, true); @@ -49,7 +50,7 @@ public: hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr(); } - /// @brief After benchmark clean-up + /// @brief Cleans up after the test. void TearDown(::benchmark::State const&) override { try { hdsptr_->rollback(); @@ -63,7 +64,8 @@ public: } }; -// This benchmark measures insertion of new hosts. +/// Defines steps necessary for conducting a benchmark that measures +/// hosts insertion. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -72,7 +74,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, insertHosts)(benchmark::State& st } } -// This benchmark measures update of existing hosts. +/// Defines steps necessary for conducting a benchmark that measures +/// hosts update. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -81,7 +84,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, updateHosts)(benchmark::State& st } } -// This benchmark +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -90,6 +94,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::St } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll4(hw-addr, duid) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -98,6 +104,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAll)(benchmark::State& state) } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll(v4-reservation) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -106,6 +114,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& s } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -114,6 +124,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -122,6 +134,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(subnet-id, v4-reservation) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -130,6 +144,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::S } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -138,6 +154,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -146,6 +164,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, ip-address) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -154,6 +174,8 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::Stat } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(ip-prefix, prefix-len) call. BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { diff --git a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc index 5f21cd8591..2179f6415f 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc @@ -22,20 +22,19 @@ #include #include -using namespace isc::dhcp; +using namespace isc::dhcp::bench; using namespace isc::dhcp::test; +using namespace isc::dhcp; using namespace std; -using namespace isc::dhcp::bench; namespace { /// @brief This is a fixture class used for benchmarking Cassandra lease backend class CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark { public: - - /// @brief Prepares the benchmark to run + /// @brief Setup routine. /// - /// Destroys and then recreates CQL schema, initializes CQL LeaseMgr. + /// It cleans up schema and recreates tables, then instantiates LeaseMgr void SetUp(::benchmark::State const&) override { destroyCqlSchema(false, true); createCqlSchema(false, true); @@ -49,7 +48,7 @@ public: lmptr_ = &(LeaseMgrFactory::instance()); } - /// @brief Cleans up after the benchmark. + /// @brief Cleans up after the test. void TearDown(::benchmark::State const&) override { try { lmptr_->rollback(); @@ -176,7 +175,7 @@ BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::St // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid // and subnet-id. BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid) - (benchmark::State& state) { + (benchmark::State& state) { const size_t lease_count = state.range(0); while (state.KeepRunning()) { setUpWithInserts6(state, lease_count); diff --git a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc index 11b0655510..ce6e738af5 100644 --- a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc @@ -12,9 +12,10 @@ #include #include -using namespace isc::dhcp; -using namespace isc::dhcp::test; using namespace isc::dhcp::bench; +using namespace isc::dhcp::test; +using namespace isc::dhcp; +using namespace std; namespace { @@ -29,12 +30,12 @@ public: : io4_(""), io6_("") { } - /// @brief Prepares the benchmark to run. + /// @brief Setup routine. /// /// Removes any files left over from earlier test, destroys any existing - /// lease manager, and then starts a new memfile mease manager. + /// lease manager, and then starts a new memfile lease manager. /// The state parameter is ignored. - void SetUp(::benchmark::State const& ) override { + void SetUp(::benchmark::State const&) override { io4_ = LeaseFileIO(getLeaseFilePath("leasefile4_0.csv")); io6_ = LeaseFileIO(getLeaseFilePath("leasefile6_0.csv")); @@ -114,7 +115,7 @@ public: } } - /// @brief Cleanup after a benchmark + /// @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 @@ -271,6 +272,7 @@ BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State } } + /// The following macros define run parameters for previously defined /// memfile benchmarks. diff --git a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc index 4eb39ce621..a06e9b788f 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc @@ -1,3 +1,4 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2017 Deutsche Telekom AG. // // Authors: Andrei Pavel @@ -20,7 +21,6 @@ #include #include #include - #include using namespace isc::dhcp::bench; @@ -36,7 +36,7 @@ public: /// @brief Setup routine. /// - /// It cleans up schema and recreates tables, then instantiates LeaseMgr + /// It cleans up schema and recreates tables, then instantiates HostMgr void SetUp(::benchmark::State const&) override { destroyMySQLSchema(false); createMySQLSchema(false); diff --git a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc index 0c88e25585..c856a25ac9 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc @@ -1,3 +1,4 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2017 Deutsche Telekom AG. // // Authors: Andrei Pavel @@ -88,8 +89,7 @@ BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& } } -// Defines a benchmark that measures IPv4 leases retrieval by hardware address -// and subnet-id. +// 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()) { @@ -175,7 +175,7 @@ BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark:: // Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid // and subnet-id. BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid) - (benchmark::State& state) { + (benchmark::State& state) { const size_t lease_count = state.range(0); while (state.KeepRunning()) { setUpWithInserts6(state, lease_count); @@ -192,10 +192,10 @@ BENCHMARK_DEFINE_F(MySqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& } } + /// The following macros define run parameters for previously defined /// MySQL benchmarks. - /// A benchmark that measures IPv4 leases insertion. BENCHMARK_REGISTER_F(MySqlLeaseMgrBenchmark, insertLeases4) ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT); diff --git a/src/lib/dhcpsrv/benchmarks/parameters.h b/src/lib/dhcpsrv/benchmarks/parameters.h index 5a321a7264..2de54f93ce 100644 --- a/src/lib/dhcpsrv/benchmarks/parameters.h +++ b/src/lib/dhcpsrv/benchmarks/parameters.h @@ -36,8 +36,8 @@ constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; /// @} -}; -}; -}; +} +} +} #endif diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc index 5245e9d6d8..9dfd14299a 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc @@ -1,3 +1,4 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2017 Deutsche Telekom AG. // // Authors: Andrei Pavel @@ -29,8 +30,13 @@ 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 { destroyPgSQLSchema(false); createPgSQLSchema(false); @@ -44,6 +50,7 @@ public: hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr(); } + /// @brief Cleans up after the test. void TearDown(::benchmark::State const&) override { try { hdsptr_->rollback(); @@ -57,6 +64,8 @@ public: } }; +/// 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()) { @@ -65,6 +74,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, insertHosts)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts update. BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -73,6 +84,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, updateHosts)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -81,6 +94,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark:: } } +/// 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()) { @@ -89,6 +104,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAll)(benchmark::State& state } } +/// 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()) { @@ -97,6 +114,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -105,6 +124,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchma } } +/// 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()) { @@ -113,6 +134,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchma } } +/// 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()) { @@ -121,6 +144,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark: } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -129,6 +154,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchma } } +/// 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()) { @@ -137,6 +164,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchma } } +/// 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()) { @@ -145,6 +174,8 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::St } } +/// 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()) { diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc index 4080b6a2d9..cad7acc978 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc @@ -23,13 +23,13 @@ #include using namespace isc::dhcp::bench; -using namespace isc::dhcp; using namespace isc::dhcp::test; +using namespace isc::dhcp; using namespace std; namespace { -/// @brief This is a fixture class used for benchmarking Postgres lease backend +/// @brief This is a fixture class used for benchmarking PostgreSQL lease backend class PgSqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark { public: /// @brief Setup routine. @@ -192,8 +192,9 @@ BENCHMARK_DEFINE_F(PgSqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& } } + /// The following macros define run parameters for previously defined -/// Postgres benchmarks. +/// PostgreSQL benchmarks. /// A benchmark that measures IPv4 leases insertion. BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, insertLeases4) @@ -244,11 +245,13 @@ BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getLease6_type_address) 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 and iaid. +/// 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 IPv4 leases retrieval. +/// A benchmark that measures expired IPv6 leases retrieval. BENCHMARK_REGISTER_F(PgSqlLeaseMgrBenchmark, getExpiredLeases6) ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT); + } // namespace diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index e9cdcbf942..037172f2b1 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -64,7 +64,6 @@ GenericLeaseMgrTest::GenericLeaseMgrTest() /// a template leasetype6_.push_back(LEASETYPE6[i]); } - } GenericLeaseMgrTest::~GenericLeaseMgrTest() { @@ -1083,7 +1082,6 @@ GenericLeaseMgrTest::testGetLease4HWAddrSubnetId() { leases[1]->subnet_id_), isc::dhcp::MultipleRecords); - } void @@ -1175,7 +1173,7 @@ GenericLeaseMgrTest::testGetLease4ClientIdSize() { leases[1]->client_id_.reset(new ClientId(clientid_vec)); EXPECT_TRUE(lmptr_->addLease(leases[1])); Lease4Collection returned = lmptr_->getLease4(*leases[1]->client_id_); - ASSERT_TRUE(returned.size() == 1); + ASSERT_EQ(returned.size(), 1u); detailCompareLease(leases[1], *returned.begin()); (void) lmptr_->deleteLease(leases[1]->addr_); } @@ -1973,7 +1971,6 @@ GenericLeaseMgrTest::testDeleteExpiredReclaimedLeases4() { EXPECT_FALSE(lease) << "The following lease should have been" " deleted: " << leases[i]->toText(); ++should_delete_num; - } else { // If the lease is not reclaimed or it has expired less than // 15 seconds ago, the lease should still be there. @@ -1981,6 +1978,7 @@ GenericLeaseMgrTest::testDeleteExpiredReclaimedLeases4() { " deleted: " << leases[i]->toText(); } } + // Check that the number of leases deleted is correct. EXPECT_EQ(deleted_num, should_delete_num); diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h index 29694760bf..5f4eaea952 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h @@ -15,7 +15,6 @@ namespace isc { namespace dhcp { namespace test { - /// @brief typedefs to simplify lease statistic testing typedef std::map StatValMap; typedef std::pair StatValPair; @@ -27,12 +26,8 @@ typedef std::vector StatValMapList; /// All concrete LeaseMgr test classes should be derived from it. class GenericLeaseMgrTest : public ::testing::Test { public: - /// @brief Universe (V4 or V6). - enum Universe { - V4, - V6 - }; + enum Universe { V4, V6 }; /// @brief Default constructor. GenericLeaseMgrTest(); diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index 9ac60d1cac..8d23f26993 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -873,7 +873,7 @@ TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetId) { /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), -/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id. +/// updateLease4() and deleteLease can handle NULL client-id. /// (client-id is optional and may not be present) TEST_F(MemfileLeaseMgrTest, lease4NullClientId) { startBackend(V4); @@ -1922,4 +1922,4 @@ TEST_F(MemfileLeaseMgrTest, wipeLeases6) { testWipeLeases6(); } -}; // end of anonymous namespace +} // namespace