OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[core] Reuse per-source test mechanism for file_load_benchmark (#37716)
Alicja Miloszewskaf3dc0284526a
diff --git a/src/core/tests/CMakeLists.txt b/src/core/tests/CMakeLists.txtindex a585e377832..59575d0a224 100644--- a/src/core/tests/CMakeLists.txt+++ b/src/core/tests/CMakeLists.txt@@ -97,6 +97,10 @@ set(OV_CORE_TESTS_SRCS${CMAKE_CURRENT_SOURCE_DIR}/weight_sharing_util_test.cpp)+if(ENABLE_TESTS_PER_SOURCE)+ list(APPEND OV_CORE_TESTS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/file_load_benchmark.cpp)+endif()+include(conditional_compilation/sources.cmake)include(frontend/sources.cmake)include(pass/sources.cmake)@@ -141,9 +145,9 @@ ov_add_test_target(CHECK_SOURCES_LISTEDCHECK_SOURCES_EXCLUDE_TARGETSopenvino_mock1_frontend- ov_file_load_benchmarkCHECK_SOURCES_EXCLUDE_FILES${CMAKE_CURRENT_SOURCE_DIR}/dnnl.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/file_load_benchmark.cpp)target_include_directories(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:openvino_core_obj,SOURCE_DIR>/src@@ -187,12 +191,5 @@ endif()ov_build_target_faster(${TARGET_NAME} PCH)-set(BENCHMARK_TARGET_NAME ov_file_load_benchmark)-add_executable(${BENCHMARK_TARGET_NAME} EXCLUDE_FROM_ALL- ${CMAKE_CURRENT_SOURCE_DIR}/file_load_benchmark.cpp)-target_link_libraries(${BENCHMARK_TARGET_NAME} PRIVATE- common_test_utils- openvino::util)-target_include_directories(${BENCHMARK_TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})add_subdirectory(frontend)diff --git a/src/core/tests/file_load_benchmark.cpp b/src/core/tests/file_load_benchmark.cppindex ba45fae88b6..9bc9e4457f5 100644--- a/src/core/tests/file_load_benchmark.cpp+++ b/src/core/tests/file_load_benchmark.cpp@@ -39,13 +39,6 @@#include "common_test_utils/common_utils.hpp"#include "common_test_utils/file_utils.hpp"-// These benchmarks measure wall-clock timing and are meaningless (and extremely slow for-// multi-GB files) in a Debug (-O0) build.-#ifndef NDEBUG-# error \- "file_load_benchmark.cpp must be built in Release mode: rebuild with -DCMAKE_BUILD_TYPE=Release, or delete this #error to build in Debug anyway."-#endif-namespace ov::test {namespace {@@ -287,9 +280,18 @@ void native_stream_read(const std::filesystem::path& path, size_t file_size) {} // namespace-// See developer_benchmarks.md for build/run instructions.+// See file_load_benchmark_guide.md for build/run instructions.-class FileLoadBenchmark : public ::testing::Test {};+class FileLoadBenchmark : public ::testing::Test {+protected:+ void SetUp() override {+#ifndef NDEBUG+ // These benchmarks measure wall-clock timing and are meaningless (and extremely slow for+ // multi-GB files) in a Debug (-O0) build. Build in Release for meaningful results.+ GTEST_SKIP() << "FileLoadBenchmark is a Release-only benchmark; rebuild with -DCMAKE_BUILD_TYPE=Release, or remove the skip to run it in Debug.";+#endif+ }+};TEST_F(FileLoadBenchmark, native_stream_vs_parallel_stream) {const std::vector<size_t> sizes_bytes = {2 * util::one_mib,diff --git a/src/core/tests/file_load_benchmark_guide.md b/src/core/tests/file_load_benchmark_guide.mdindex d681cb99ab8..bad1830f06d 100644--- a/src/core/tests/file_load_benchmark_guide.md+++ b/src/core/tests/file_load_benchmark_guide.md@@ -3,19 +3,24 @@Developer-only benchmarks for comparing file-loading strategies. Use these to evaluate I/Operformance on new hardware or to validate changes to `ov::MappedMemory`.-These tests are **not compiled by default** — the target uses `EXCLUDE_FROM_ALL`.+These tests are **not compiled by default**. The executable is built only when the+developer option `ENABLE_TESTS_PER_SOURCE=ON` is set, and even then the target is+`EXCLUDE_FROM_ALL` — it must be built explicitly by name. `ENABLE_TESTS_PER_SOURCE` is a+developer-only flag and is not enabled in CI.++**Build in Release.** In a Debug build the file still compiles, but every `FileLoadBenchmark` test is **skipped**, because the measurements are meaningless without optimizations.## Build```bash-cmake -DENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release <other flags> ..-cmake --build <dir> --target ov_file_load_benchmark+cmake -DENABLE_TESTS=ON -DENABLE_TESTS_PER_SOURCE=ON -DCMAKE_BUILD_TYPE=Release <other flags> ..+cmake --build <dir> --target ov_core_unit_tests_file_load_benchmark```## Run```bash-./ov_file_load_benchmark --gtest_filter=*FileLoadBenchmark*+./ov_core_unit_tests_file_load_benchmark```## Environment Requirements