rocksdb/microbench/CMakeLists.txt
Jay Zhuang 5dd18a8d8e Add micro-benchmark support (#8493)
Summary:
Add google benchmark for microbench.
Add ribbon_bench for benchmark ribbon filter vs. other filters.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8493

Test Plan:
added test to CI
To run the benchmark on devhost:
Install benchmark: `$ sudo dnf install google-benchmark-devel`
Build and run:
`$ ROCKSDB_NO_FBCODE=1 DEBUG_LEVEL=0 make microbench`
or with cmake:
`$ mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_BENCHMARK=1 && make microbench`

Reviewed By: pdillinger

Differential Revision: D29589649

Pulled By: jay-zhuang

fbshipit-source-id: 8fed13b562bef4472f161ecacec1ab6b18911dff
2021-07-08 18:22:45 -07:00

17 lines
719 B
CMake

find_package(benchmark REQUIRED)
find_package(Threads REQUIRED)
file(GLOB_RECURSE ALL_BENCH_CPP *.cc)
foreach(ONE_BENCH_CPP ${ALL_BENCH_CPP})
get_filename_component(TARGET_NAME ${ONE_BENCH_CPP} NAME_WE)
add_executable(${TARGET_NAME} ${ONE_BENCH_CPP})
target_link_libraries(${TARGET_NAME} ${ROCKSDB_LIB} benchmark::benchmark
${CMAKE_THREAD_LIBS_INIT})
# run benchmark like a test, if added, the benchmark tests could be run by `ctest -R Bench_`
# add_test(Bench_${TARGET_NAME} ${TARGET_NAME})
list(APPEND ALL_BENCH_TARGETS ${TARGET_NAME})
endforeach()
add_custom_target(microbench
COMMAND for t in ${ALL_BENCH_TARGETS}\; do \.\/$$t \|\| exit 1\; done
DEPENDS ${ALL_BENCH_TARGETS})