diff --git a/.gitmodules b/.gitmodules index 352f749c199a50bd3de6e9e061d2606922693490..92fd4e652fd487fbf22acbcf1e6da4bb0dd0b207 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "thirdparty/Catch2"] path = thirdparty/Catch2 url = https://github.com/catchorg/Catch2.git +[submodule "thirdparty/google/googletest"] + path = thirdparty/google/googletest + url = https://github.com/google/googletest.git +[submodule "thirdparty/google/benchmark"] + path = thirdparty/google/benchmark + url = https://github.com/google/benchmark.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 98121caad3d67b769fa6906f60213ddec66ce087..64b259243708dc4c69e582c268871a1ecb895a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Google benchmark submodule for micro benchmarking. This will enabled future optimisation + - Benchmark tests for QueryBuilder + ## [0.9.0] - 2019-07-12 ### Added -* Pre v1 release of the library. This is an almost complete version of the library. Next couple of versions will complete the library before a v1 release. \ No newline at end of file +- Pre v1 release of the library. + - This is an almost complete version of the library. + - Next couple of versions will complete the library before a v1 release. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 507e79529dee82b6ea238e913423b8da810b0a5f..346a4cdc0d0be8b8cd8bf1a0df9b44d262f4aa6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,12 +34,18 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Build options option(BUILD_UNIT_TESTS "Build unit tests" OFF) +option(BUILD_BENCHMARK_TESTS "Build benchmarking tests (Forces RELEASE build)" OFF) option(ENABLE_CLANG "Enable clang code and layout analysis" OFF) if(BUILD_UNIT_TESTS) message(STATUS "Unit tests will be built") endif(BUILD_UNIT_TESTS) +if(BUILD_BENCHMARK_TESTS) + message(STATUS "Benchmark tests will be built (Forces RELEASE build)") + set(CMAKE_BUILD_TYPE "Release") +endif(BUILD_BENCHMARK_TESTS) + # arch install definitions include(GNUInstallDirs) @@ -69,6 +75,16 @@ find_package(Tango) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) +# Thirdparty Integration ----------------------------------- + +# build google benchmark (target: benchmark) +# do not build tests of benchmarking lib +set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORCE) +add_subdirectory(thirdparty/google/benchmark) + +# build tests (targets: gtest_main, gtest) +add_subdirectory(thirdparty/google/googletest/googletest) + # Include the thirdparty projects add_subdirectory(thirdparty/libhdbpp EXCLUDE_FROM_ALL) add_subdirectory(thirdparty/libpqxx EXCLUDE_FROM_ALL) @@ -168,4 +184,8 @@ install( # Tests ----------------------------------- if(BUILD_UNIT_TESTS) add_subdirectory(test) -endif(BUILD_UNIT_TESTS) \ No newline at end of file +endif(BUILD_UNIT_TESTS) + +if(BUILD_BENCHMARK_TESTS) + add_subdirectory(benchmark) +endif(BUILD_BENCHMARK_TESTS) \ No newline at end of file diff --git a/src/LibUtils.cpp b/src/LibUtils.cpp index 4ff971378d171fc3cfb6a16e82e75cb25d6e5150..9be85ba0a6d3dcbb4acaf45d74f45c1357844226 100644 --- a/src/LibUtils.cpp +++ b/src/LibUtils.cpp @@ -175,10 +175,19 @@ void LogConfigurator::initLogging(bool enable_file, bool enable_console, const s catch (const spdlog::spdlog_ex &ex) { string msg {"Failed to initialise the logging system, caught error: " + string(ex.what())}; + cout << msg << endl; Tango::Except::throw_exception("Runtime Error", msg, LOCATION_INFO); } } +//============================================================================= +//============================================================================= +void LogConfigurator::initLoggingMetrics(bool enable_file, bool enable_console, const string &log_file_name) +{ + auto logger = spdlog::get(LibLoggerName); + if (!logger) initLogging(enable_file, enable_console, log_file_name); +} + //============================================================================= //============================================================================= void LogConfigurator::shutdownLogging() diff --git a/src/LibUtils.hpp b/src/LibUtils.hpp index 1fabc1b7c191bfb5003a5217e0d15118025826c3..23beb84824afe40bb006717fca2441345ffbbc0c 100644 --- a/src/LibUtils.hpp +++ b/src/LibUtils.hpp @@ -64,6 +64,11 @@ const string LibLoggerName = "hdbpp"; struct LogConfigurator { static void initLogging(bool enable_file, bool enable_console, const std::string &log_file_name = ""); + + // this version is used for metrics testing, and ignores the call if the + // logger already exists + static void initLoggingMetrics(bool enable_file, bool enable_console, const std::string &log_file_name = ""); + static void shutdownLogging(); static void setLoggingLevel(spdlog::level::level_enum level); }; diff --git a/src/QueryBuilder.hpp b/src/QueryBuilder.hpp index a8828073fab74605a066f92b1049ec9fe16a1fba..79cb042d34af857a38124de69cac861db0d85e1d 100644 --- a/src/QueryBuilder.hpp +++ b/src/QueryBuilder.hpp @@ -30,7 +30,7 @@ namespace std { -// This is a custom compariator for the AttributeTraits class to allow its +// This is a custom comparator for the AttributeTraits class to allow its // use as a key in a map. The traits class is used as a key to reference // cached queries template<> diff --git a/thirdparty/google/benchmark b/thirdparty/google/benchmark new file mode 160000 index 0000000000000000000000000000000000000000..090faecb454fbd6e6e17a75ef8146acb037118d4 --- /dev/null +++ b/thirdparty/google/benchmark @@ -0,0 +1 @@ +Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4 diff --git a/thirdparty/google/googletest b/thirdparty/google/googletest new file mode 160000 index 0000000000000000000000000000000000000000..2ef13f524b837a68bae27ae1123da0400dff6285 --- /dev/null +++ b/thirdparty/google/googletest @@ -0,0 +1 @@ +Subproject commit 2ef13f524b837a68bae27ae1123da0400dff6285