1- # Copyright (C) 2023 Intel Corporation
1+ # Copyright (C) 2023-2024 Intel Corporation
22# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
5+ include (FetchContent)
6+ FetchContent_Declare(
7+ googlebenchmark
8+ GIT_REPOSITORY https://github.com/google/benchmark.git
9+ GIT_TAG v1.9.0)
10+
11+ set (BENCHMARK_ENABLE_GTEST_TESTS
12+ OFF
13+ CACHE BOOL "" FORCE)
14+ set (BENCHMARK_ENABLE_TESTING
15+ OFF
16+ CACHE BOOL "" FORCE)
17+ set (BENCHMARK_ENABLE_INSTALL
18+ OFF
19+ CACHE BOOL "" FORCE)
20+ FetchContent_MakeAvailable(googlebenchmark)
21+
522# In MSVC builds, there is no way to determine the actual build type during the
623# CMake configuration step. Therefore, this message is printed in all MSVC
724# builds.
@@ -32,7 +49,7 @@ function(add_umf_benchmark)
3249 "${multiValueArgs} "
3350 ${ARGN} )
3451
35- set (BENCH_NAME umf-bench- ${ARG_NAME} )
52+ set (BENCH_NAME umf-${ARG_NAME} )
3653
3754 set (BENCH_LIBS ${ARG_LIBS} umf)
3855
@@ -55,13 +72,17 @@ function(add_umf_benchmark)
5572 COMMAND ${BENCH_NAME}
5673 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
5774
58- # Benchmark passes if it prints "PASSED" in the output, because ubench of
59- # scalable pool fails if the confidence interval exceeds maximum permitted
60- # 2.5%.
61- set_tests_properties (
62- ${BENCH_NAME} PROPERTIES
63- LABELS "benchmark"
64- PASS_REGULAR_EXPRESSION "PASSED" )
75+ if ("${BENCH_NAME} " STREQUAL "umf-ubench" )
76+ # Benchmark passes if it prints "PASSED" in the output, because ubench
77+ # of scalable pool fails if the confidence interval exceeds maximum
78+ # permitted 2.5%.
79+ set_tests_properties (
80+ ${BENCH_NAME} PROPERTIES
81+ LABELS "benchmark"
82+ PASS_REGULAR_EXPRESSION "PASSED" )
83+ else ()
84+ set_tests_properties (${BENCH_NAME} PROPERTIES LABELS "benchmark" )
85+ endif ()
6586
6687 if (WINDOWS)
6788 # append PATH to DLLs
@@ -120,6 +141,12 @@ add_umf_benchmark(
120141 LIBS ${LIBS_OPTIONAL}
121142 LIBDIRS ${LIB_DIRS} )
122143
144+ add_umf_benchmark(
145+ NAME benchmark
146+ SRCS benchmark.cpp
147+ LIBS ${LIBS_OPTIONAL} benchmark::benchmark
148+ LIBDIRS ${LIB_DIRS} )
149+
123150if (UMF_BUILD_BENCHMARKS_MT)
124151 add_umf_benchmark(
125152 NAME multithreaded
0 commit comments