diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ef473a..1fe770f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,12 +288,14 @@ if (BUILD_UNIT_TESTS) set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "benchmark tests") add_subdirectory(${GOOGLEBENCH_DIR}) link_directories(${CMAKE_BINARY_DIR}/${GOOGLEBENCH_DIR}) - set(GOOGLEBENCH_LIBRARIES benchmark) file(GLOB_RECURSE TEST_SOURCES "encfs/*_test.cpp") - add_executable (unittests ${TEST_SOURCES}) target_link_libraries(unittests gtest gtest_main encfs) + + file(GLOB_RECURSE BENCH_SOURCES "encfs/*_bench.cpp") + add_executable (benchmarks ${BENCH_SOURCES}) + target_link_libraries(benchmarks benchmark encfs) endif () add_custom_target(tests COMMAND ${CMAKE_CURRENT_LIST_DIR}/test.sh) diff --git a/encfs/MemoryPool_bench.cpp b/encfs/MemoryPool_bench.cpp new file mode 100644 index 0000000..9326e43 --- /dev/null +++ b/encfs/MemoryPool_bench.cpp @@ -0,0 +1,14 @@ +#include "benchmark/benchmark.h" + +#include "MemoryPool.h" + +using namespace encfs; + +static void BM_MemPoolAllocate(benchmark::State& state) { + while (state.KeepRunning()) { + auto block = MemoryPool::allocate(1024); + MemoryPool::release(block); + } +} +// Register the function as a benchmark +BENCHMARK(BM_MemPoolAllocate); diff --git a/encfs/main_bench.cpp b/encfs/main_bench.cpp new file mode 100644 index 0000000..a78145f --- /dev/null +++ b/encfs/main_bench.cpp @@ -0,0 +1,3 @@ +#include "benchmark/benchmark.h" + +BENCHMARK_MAIN(); \ No newline at end of file