File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
- # Step 1: Check if CODSPEED_MODE is set via the command line
1
+ add_subdirectory (${PROJECT_SOURCE_DIR} /../core codspeed)
2
+
3
+ execute_process (
4
+ COMMAND git rev-parse --show-toplevel
5
+ OUTPUT_VARIABLE GIT_ROOT_DIR
6
+ OUTPUT_STRIP_TRAILING_WHITESPACE
7
+ RESULT_VARIABLE GIT_COMMAND_RESULT
8
+ )
9
+
10
+ if (NOT GIT_COMMAND_RESULT EQUAL 0)
11
+ message (
12
+ WARNING
13
+ "Failed to determine the git root directory.\
14
+ Check that git is in your PATH, and that you are in a git repository.\
15
+ Continuing, but codspeed features will not be useable"
16
+ )
17
+ # Default to user's cmake source directory
18
+ set (GIT_ROOT_DIR ${CMAKE_SOURCE_DIR} )
19
+ endif ()
20
+
21
+ target_compile_definitions (
22
+ codspeed
23
+ INTERFACE -DCODSPEED_GIT_ROOT_DIR="${GIT_ROOT_DIR} "
24
+ )
2
25
3
26
if (DEFINED CODSPEED_MODE)
4
27
# Define a preprocessor macro based on the build mode
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
171
171
#include < cstddef>
172
172
#include < initializer_list>
173
173
#include < iosfwd>
174
+ #include < iostream>
174
175
#include < limits>
175
176
#include < map>
176
177
#include < memory>
@@ -1437,11 +1438,23 @@ class Fixture : public internal::Benchmark {
1437
1438
static ::benchmark::internal::Benchmark const * const BENCHMARK_PRIVATE_NAME ( \
1438
1439
n) [[maybe_unused]]
1439
1440
1441
+ #ifdef CODSPEED_INSTRUMENTATION
1442
+ #include < filesystem>
1443
+ #define BENCHMARK (...) \
1444
+ BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
1445
+ (::benchmark::internal::RegisterBenchmarkInternal( \
1446
+ std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1447
+ std::filesystem::relative (__FILE__, CODSPEED_GIT_ROOT_DIR) \
1448
+ .string() + \
1449
+ "::" + #__VA_ARGS__, \
1450
+ __VA_ARGS__)))
1451
+ #else
1440
1452
#define BENCHMARK (...) \
1441
1453
BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
1442
1454
(::benchmark::internal::RegisterBenchmarkInternal( \
1443
1455
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
1444
1456
#__VA_ARGS__, __VA_ARGS__)))
1457
+ #endif
1445
1458
1446
1459
// Old-style macros
1447
1460
#define BENCHMARK_WITH_ARG (n, a ) BENCHMARK(n)->Arg ((a))
You can’t perform that action at this time.
0 commit comments