Skip to content
Snippets Groups Projects
Commit 5f94e79c authored by Stuart Mark James's avatar Stuart Mark James
Browse files

Added google benchmark and some initial tests

parent e6979342
Branches
Tags
No related merge requests found
...@@ -7,3 +7,9 @@ ...@@ -7,3 +7,9 @@
[submodule "thirdparty/Catch2"] [submodule "thirdparty/Catch2"]
path = thirdparty/Catch2 path = thirdparty/Catch2
url = https://github.com/catchorg/Catch2.git 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
...@@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ...@@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
### Added
- Google benchmark submodule for micro benchmarking. This will enabled future optimisation
- Benchmark tests for QueryBuilder
## [0.9.0] - 2019-07-12 ## [0.9.0] - 2019-07-12
### Added ### 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. - Pre v1 release of the library.
\ No newline at end of file - 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
...@@ -34,12 +34,18 @@ set(CMAKE_CXX_EXTENSIONS OFF) ...@@ -34,12 +34,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Build options # Build options
option(BUILD_UNIT_TESTS "Build unit tests" OFF) 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) option(ENABLE_CLANG "Enable clang code and layout analysis" OFF)
if(BUILD_UNIT_TESTS) if(BUILD_UNIT_TESTS)
message(STATUS "Unit tests will be built") message(STATUS "Unit tests will be built")
endif(BUILD_UNIT_TESTS) 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 # arch install definitions
include(GNUInstallDirs) include(GNUInstallDirs)
...@@ -69,6 +75,16 @@ find_package(Tango) ...@@ -69,6 +75,16 @@ find_package(Tango)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) 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 # Include the thirdparty projects
add_subdirectory(thirdparty/libhdbpp EXCLUDE_FROM_ALL) add_subdirectory(thirdparty/libhdbpp EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/libpqxx EXCLUDE_FROM_ALL) add_subdirectory(thirdparty/libpqxx EXCLUDE_FROM_ALL)
...@@ -169,3 +185,7 @@ install( ...@@ -169,3 +185,7 @@ install(
if(BUILD_UNIT_TESTS) if(BUILD_UNIT_TESTS)
add_subdirectory(test) add_subdirectory(test)
endif(BUILD_UNIT_TESTS) endif(BUILD_UNIT_TESTS)
if(BUILD_BENCHMARK_TESTS)
add_subdirectory(benchmark)
endif(BUILD_BENCHMARK_TESTS)
\ No newline at end of file
...@@ -175,10 +175,19 @@ void LogConfigurator::initLogging(bool enable_file, bool enable_console, const s ...@@ -175,10 +175,19 @@ void LogConfigurator::initLogging(bool enable_file, bool enable_console, const s
catch (const spdlog::spdlog_ex &ex) catch (const spdlog::spdlog_ex &ex)
{ {
string msg {"Failed to initialise the logging system, caught error: " + string(ex.what())}; 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); 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() void LogConfigurator::shutdownLogging()
......
...@@ -64,6 +64,11 @@ const string LibLoggerName = "hdbpp"; ...@@ -64,6 +64,11 @@ const string LibLoggerName = "hdbpp";
struct LogConfigurator struct LogConfigurator
{ {
static void initLogging(bool enable_file, bool enable_console, const std::string &log_file_name = ""); 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 shutdownLogging();
static void setLoggingLevel(spdlog::level::level_enum level); static void setLoggingLevel(spdlog::level::level_enum level);
}; };
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
namespace std 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 // use as a key in a map. The traits class is used as a key to reference
// cached queries // cached queries
template<> template<>
......
Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4
Subproject commit 2ef13f524b837a68bae27ae1123da0400dff6285
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment