File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ bench: BUILD_BENCH := ON
3333bench : build
3434 @cmake --build " $( BUILD_DIR) " -j$(JOBS )
3535
36+ run-benchmarks : bench
37+ @cmake --build " $( BUILD_DIR) " --target run_all_benchmarks -- -j$(JOBS )
38+
3639tools : BUILD_TOOLS := ON
3740tools : build
3841
5053 @echo " build - configure and build"
5154 @echo " test - run ctest (RUN_TESTS=ON)"
5255 @echo " bench - build & run benchmarks (BUILD_BENCH=ON)"
56+ @echo " run-benchmarks - run all benchmarks"
5357 @echo " tools - build project-defined tools (BUILD_TOOLS=ON)"
5458 @echo " format - run clang-format on all source files"
5559 @echo " clean - clean build artefacts"
Original file line number Diff line number Diff line change @@ -39,6 +39,39 @@ foreach(BENCHMARK_FILE ${BENCHMARK_FILES})
3939 add_executable (${FINAL_TARGET_NAME} ${BENCHMARK_FILE} )
4040 set_target_properties (${FINAL_TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BENCHMARK_BINARY_DIR} )
4141 target_link_libraries (${FINAL_TARGET_NAME} PRIVATE cpl benchmark::benchmark)
42+
43+ list (APPEND BENCHMARK_TARGETS ${FINAL_TARGET_NAME} )
44+ endforeach ()
45+
46+ execute_process (
47+ COMMAND git rev-parse --short HEAD
48+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} "
49+ OUTPUT_VARIABLE GIT_HASH
50+ OUTPUT_STRIP_TRAILING_WHITESPACE
51+ )
52+
53+ string (TIMESTAMP TODAY "%Y-%m-%d_%H-%M-%S" )
54+ set (RESULT_DIR "${CMAKE_BINARY_DIR} /benchmarks/results" )
55+ file (MAKE_DIRECTORY "${RESULT_DIR} " )
56+ set (BENCH_JSONS "" )
57+
58+ foreach (TGT IN LISTS BENCHMARK_TARGETS)
59+ set (JSON_OUT "${RESULT_DIR} /${TODAY} _${GIT_HASH} _${TGT} .json" )
60+
61+ add_custom_command (
62+ OUTPUT "${JSON_OUT} "
63+ COMMAND ${CMAKE_COMMAND} -E echo "→ running ${TGT} "
64+ COMMAND $<TARGET_FILE:${TGT} >
65+ --benchmark_out=${JSON_OUT}
66+ --benchmark_out_format=json
67+ DEPENDS ${TGT}
68+ COMMENT "Running benchmark '${TGT} ' and writing ${JSON_OUT} "
69+ VERBATIM
70+ )
71+
72+ list (APPEND BENCH_JSONS "${JSON_OUT} " )
4273endforeach ()
4374
75+ add_custom_target (run_all_benchmarks ALL DEPENDS ${BENCH_JSONS} )
76+
4477include_directories (BEFORE ${CMAKE_SOURCE_DIR} /cpl/inc)
You can’t perform that action at this time.
0 commit comments