Skip to content

Commit f782c94

Browse files
committed
Move to use generation of flamegraphs as a CLEANUP_FIXTURE
1 parent 09a58ea commit f782c94

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

cmake/modules/AddRootBench.cmake

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ function(RB_ADD_SETUP_FIXTURE benchmark)
2929
endfunction(RB_ADD_SETUP_FIXTURE)
3030

3131

32+
#----------------------------------------------------------------------------
33+
# function RB_ADD_FLAMEGRAPHCPU_FIXTURE(<benchmark>)
34+
#----------------------------------------------------------------------------
35+
function(RB_ADD_FLAMEGRAPHCPU_FIXTURE benchmark)
36+
cmake_parse_arguments(ARG "" "" "" ${ARGN})
37+
add_test(NAME rootbench-fixture-flamegraphcpu-${benchmark}
38+
COMMAND ${PROJECT_BINARY_DIR}/tools/flamegraph.sh -d ${PROJECT_BINARY_DIR} -b ${CMAKE_CURRENT_BINARY_DIR}/${benchmark} -c)
39+
set_tests_properties(rootbench-fixture-flamegraphcpu-${benchmark} PROPERTIES FIXTURES_CLEANUP flamegraphcpu-${benchmark})
40+
endfunction(RB_ADD_FLAMEGRAPHCPU_FIXTURE)
41+
42+
43+
#----------------------------------------------------------------------------
44+
# function RB_ADD_FLAMEGRAPHMEM_FIXTURE(<benchmark>)
45+
#----------------------------------------------------------------------------
46+
function(RB_ADD_FLAMEGRAPHMEM_FIXTURE benchmark)
47+
cmake_parse_arguments(ARG "" "" "" ${ARGN})
48+
add_test(NAME rootbench-fixture-flamegraphmem-${benchmark}
49+
COMMAND ${PROJECT_BINARY_DIR}/tools/flamegraph.sh -d ${PROJECT_BINARY_DIR} -b ${CMAKE_CURRENT_BINARY_DIR}/${benchmark} -m)
50+
set_tests_properties(rootbench-fixture-flamegraphmem-${benchmark} PROPERTIES FIXTURES_CLEANUP flamegraphmem-${benchmark})
51+
endfunction(RB_ADD_FLAMEGRAPHMEM_FIXTURE)
52+
53+
54+
3255
#----------------------------------------------------------------------------
3356
# function RB_ADD_GBENCHMARK(<benchmark> source1 source2... LIBRARIES libs)
3457
#----------------------------------------------------------------------------
@@ -74,13 +97,21 @@ function(RB_ADD_GBENCHMARK benchmark)
7497
RB_ADD_SETUP_FIXTURE(${benchmark} SETUP ${ARG_SETUP})
7598
endif()
7699

100+
# Flamegraphs (both mem and cpu)
101+
if(flamegraphCPU)
102+
RB_ADD_FLAMEGRAPHCPU_FIXTURE(${benchmark})
103+
endif()
104+
if(flamegraphMem)
105+
RB_ADD_FLAMEGRAPHMEM_FIXTURE(${benchmark})
106+
endif()
107+
77108
# Add benchmark as a CTest
78109
add_test(NAME rootbench-${benchmark}
79110
COMMAND ${benchmark} --benchmark_out_format=csv --benchmark_out=rootbench-gbenchmark-${benchmark}.csv --benchmark_color=false)
80111
set_tests_properties(rootbench-${benchmark} PROPERTIES
81112
ENVIRONMENT LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH}
82113
TIMEOUT "${TIMEOUT_VALUE}" LABELS "${ARG_LABEL}" RUN_SERIAL TRUE
83-
FIXTURES_REQUIRED "setup-${benchmark};download-${benchmark}-datafiles")
114+
FIXTURES_REQUIRED "setup-${benchmark};download-${benchmark}-datafiles;flamegraphcpu-${benchmark};flamegraphmem-${benchmark}")
84115
endfunction(RB_ADD_GBENCHMARK)
85116

86117

0 commit comments

Comments
 (0)