diff --git a/apps/benchmarks/CMakeLists.txt b/apps/benchmarks/CMakeLists.txt index 18bc56ec60..6a23ac3b37 100644 --- a/apps/benchmarks/CMakeLists.txt +++ b/apps/benchmarks/CMakeLists.txt @@ -2,19 +2,4 @@ if(OPENMW_USE_SYSTEM_BENCHMARK) find_package(benchmark REQUIRED) endif() -openmw_add_executable(openmw_detournavigator_navmeshtilescache_benchmark detournavigator/navmeshtilescache.cpp) -target_compile_features(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE cxx_std_17) -target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark benchmark::benchmark components) - -if (UNIX AND NOT APPLE) - target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark ${CMAKE_THREAD_LIBS_INIT}) -endif() - -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) - target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE ) -endif() - -if (BUILD_WITH_CODE_COVERAGE) - target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage) - target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov) -endif() +add_subdirectory(detournavigator) diff --git a/apps/benchmarks/detournavigator/CMakeLists.txt b/apps/benchmarks/detournavigator/CMakeLists.txt new file mode 100644 index 0000000000..198cf2bd3c --- /dev/null +++ b/apps/benchmarks/detournavigator/CMakeLists.txt @@ -0,0 +1,15 @@ +openmw_add_executable(openmw_detournavigator_navmeshtilescache_benchmark navmeshtilescache.cpp) +target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark benchmark::benchmark components) + +if (UNIX AND NOT APPLE) + target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark ${CMAKE_THREAD_LIBS_INIT}) +endif() + +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) + target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE ) +endif() + +if (BUILD_WITH_CODE_COVERAGE) + target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage) + target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov) +endif() diff --git a/apps/benchmarks/detournavigator/navmeshtilescache.cpp b/apps/benchmarks/detournavigator/navmeshtilescache.cpp index f1d024a25f..3be1c8762a 100644 --- a/apps/benchmarks/detournavigator/navmeshtilescache.cpp +++ b/apps/benchmarks/detournavigator/navmeshtilescache.cpp @@ -191,7 +191,7 @@ namespace generateKeys(std::back_inserter(keys), keys.size() * (100 - hitPercentage) / 100, random); std::size_t n = 0; - while (state.KeepRunning()) + for (auto _ : state) { const auto& key = keys[n++ % keys.size()]; const auto result = cache.get(key.mAgentBounds, key.mTilePosition, key.mRecastMesh); diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 5ce604c50b..33908c8caf 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -221,8 +221,8 @@ if (BUILD_BENCHMARKS AND NOT OPENMW_USE_SYSTEM_BENCHMARK) include(FetchContent) FetchContent_Declare(benchmark - URL https://github.com/google/benchmark/archive/refs/tags/v1.5.2.zip - URL_HASH SHA512=1146deca3b424703800933012ef75805d4657309d58b3484498bb51a99025bd405a69855a75af59c23fc3684bfa027224513999b8d7beaab3320c96fb6d6c540 + URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip + URL_HASH SHA512=bec4016263587a57648e02b094c69e838c0a21e16c3dcfc6f03100397ab8f95d5fab1f5fd0d7e0e8adbb8212fff1eb574581158fdda1fa7fd6ff12762154b0cc SOURCE_DIR fetched/benchmark ) FetchContent_MakeAvailableExcludeFromAll(benchmark)