-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
90 lines (76 loc) · 3.76 KB
/
Copy pathCMakeLists.txt
File metadata and controls
90 lines (76 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Google Benchmark
include(FetchContent)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.8.3
)
# Disable benchmark tests
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(benchmark)
# Common benchmark settings
add_compile_options(
$<$<CONFIG:Release>:-DNDEBUG>
)
# Suppress MSVC warnings for benchmarks (intentional in benchmark code)
if(MSVC)
add_compile_options(
/wd4834 # Suppress C4834: discarding return value with [[nodiscard]] (intentional in benchmarks)
)
endif()
# All benchmarks use public headers only (detail headers now public)
set(BENCHMARK_INCLUDE_DIRS
# Empty - all headers are now in public include/
)
# Benchmark executables
add_executable(bench_orderbook_l2 bench_orderbook_l2.cpp)
target_link_libraries(bench_orderbook_l2 PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_orderbook_l2 PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_orderbook_l3 bench_orderbook_l3.cpp)
target_link_libraries(bench_orderbook_l3 PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_orderbook_l3 PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_orderbook_manager bench_orderbook_manager.cpp)
target_link_libraries(bench_orderbook_manager PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_orderbook_manager PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_observer_overhead bench_observer_overhead.cpp)
target_link_libraries(bench_observer_overhead PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_observer_overhead PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_memory_usage bench_memory_usage.cpp)
target_link_libraries(bench_memory_usage PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_memory_usage PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_market_replay bench_market_replay.cpp)
target_link_libraries(bench_market_replay PRIVATE slick::orderbook benchmark::benchmark)
target_include_directories(bench_market_replay PRIVATE ${BENCHMARK_INCLUDE_DIRS})
add_executable(bench_cache_alignment bench_cache_alignment.cpp)
target_link_libraries(bench_cache_alignment PRIVATE slick::orderbook benchmark::benchmark)
# All headers now public
target_include_directories(bench_cache_alignment PRIVATE
${CMAKE_SOURCE_DIR}/include
)
# Set linker language to C++ for all benchmarks (needed for LTO with header-only mode)
set_target_properties(
bench_orderbook_l2
bench_orderbook_l3
bench_orderbook_manager
bench_observer_overhead
bench_memory_usage
bench_market_replay
bench_cache_alignment
PROPERTIES
LINKER_LANGUAGE CXX
)
# Custom benchmark runner for all benchmarks
add_custom_target(run_benchmarks
COMMAND bench_orderbook_l2 --benchmark_out=bench_l2.json --benchmark_out_format=json
COMMAND bench_orderbook_l3 --benchmark_out=bench_l3.json --benchmark_out_format=json
COMMAND bench_orderbook_manager --benchmark_out=bench_manager.json --benchmark_out_format=json
COMMAND bench_observer_overhead --benchmark_out=bench_observer.json --benchmark_out_format=json
COMMAND bench_memory_usage --benchmark_out=bench_memory.json --benchmark_out_format=json
COMMAND bench_market_replay --benchmark_out=bench_market_replay.json --benchmark_out_format=json
COMMAND bench_cache_alignment --benchmark_out=bench_cache_alignment.json --benchmark_out_format=json
DEPENDS bench_orderbook_l2 bench_orderbook_l3 bench_orderbook_manager
bench_observer_overhead bench_memory_usage bench_market_replay bench_cache_alignment
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running all benchmarks..."
)