mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 15:33:16 +01:00
add first micro benchmark
This commit is contained in:
parent
36a4f9c4dd
commit
aa533186e3
@ -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)
|
||||
|
14
encfs/MemoryPool_bench.cpp
Normal file
14
encfs/MemoryPool_bench.cpp
Normal file
@ -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);
|
3
encfs/main_bench.cpp
Normal file
3
encfs/main_bench.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
BENCHMARK_MAIN();
|
Loading…
Reference in New Issue
Block a user