From 04bbd7f3053834f29af6c1f9a5b2b1f6ede6f403 Mon Sep 17 00:00:00 2001 From: Alex Seaton Date: Mon, 14 Oct 2024 10:47:51 +0100 Subject: [PATCH] Fix the timers macro, configure it with a cmake option The build failed with the timers enabled as new variables have been introduced in the normal code with names like `timer` that clash once the timer macros are compiled in. --- cpp/CMakeLists.txt | 5 +++++ cpp/arcticdb/entity/performance_tracing.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 03802012b1..8c0e912bb9 100755 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -25,6 +25,7 @@ option( option(ARCTICDB_USING_ADDRESS_SANITIZER "Enable address sanitizer." OFF) option(ARCTICDB_USING_THREAD_SANITIZER "Enable thread sanitizer." OFF) option(ARCTICDB_USING_UB_SANITIZER "Enable undefined behavior sanitizer." OFF) +option(ARCTICDB_LOG_PERFORMANCE "Whether to log performance timings." OFF) set(ARCTICDB_SANITIZER_FLAGS) if(${ARCTICDB_USING_ADDRESS_SANITIZER}) @@ -42,6 +43,10 @@ if(${ARCTICDB_USING_UB_SANITIZER}) message(STATUS "Building ArcticDB with UB Sanitizer") endif() +if(${ARCTICDB_LOG_PERFORMANCE}) + add_compile_definitions(ARCTICDB_LOG_PERFORMANCE) +endif() + if(ARCTICDB_SANITIZER_FLAGS) list(APPEND ARCTICDB_SANITIZER_FLAGS "-g;-fno-omit-frame-pointer;-fno-optimize-sibling-calls;") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/cpp/arcticdb/entity/performance_tracing.hpp b/cpp/arcticdb/entity/performance_tracing.hpp index b7bc575b18..ec8d0af862 100644 --- a/cpp/arcticdb/entity/performance_tracing.hpp +++ b/cpp/arcticdb/entity/performance_tracing.hpp @@ -88,22 +88,22 @@ void set_remotery_thread_name(const char* task_name); #elif defined(ARCTICDB_LOG_PERFORMANCE) #define ARCTICDB_SAMPLE(name, flags) \ -arcticdb::ScopedTimer timer{#name, [](auto msg) { \ +arcticdb::ScopedTimer _timer{#name, [](auto msg) { \ std::cout << msg; \ }}; #define ARCTICDB_SUBSAMPLE(name, flags) \ -arcticdb::ScopedTimer sub_timer_##name{#name, [](auto msg) { \ +arcticdb::ScopedTimer _sub_timer_##name{#name, [](auto msg) { \ std::cout << msg; \ }}; #define ARCTICDB_SAMPLE_DEFAULT(name) \ -arcticdb::ScopedTimer default_timer{#name, [](auto msg) { \ +arcticdb::ScopedTimer _default_timer{#name, [](auto msg) { \ std::cout << msg; \ }}; #define ARCTICDB_SUBSAMPLE_DEFAULT(name) \ -arcticdb::ScopedTimer sub_timer_##name{#name, [](auto msg) { \ +arcticdb::ScopedTimer _sub_timer_##name{#name, [](auto msg) { \ std::cout << msg; \ }};