1
- # Copyright (C) 2023 Intel Corporation
1
+ # Copyright (C) 2023-2024 Intel Corporation
2
2
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3
3
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
4
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
+
5
22
# In MSVC builds, there is no way to determine the actual build type during the
6
23
# CMake configuration step. Therefore, this message is printed in all MSVC
7
24
# builds.
@@ -32,7 +49,7 @@ function(add_umf_benchmark)
32
49
"${multiValueArgs} "
33
50
${ARGN} )
34
51
35
- set (BENCH_NAME umf-bench- ${ARG_NAME} )
52
+ set (BENCH_NAME umf-${ARG_NAME} )
36
53
37
54
set (BENCH_LIBS ${ARG_LIBS} umf)
38
55
@@ -52,13 +69,17 @@ function(add_umf_benchmark)
52
69
COMMAND ${BENCH_NAME}
53
70
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
54
71
55
- # Benchmark passes if it prints "PASSED" in the output, because ubench of
56
- # scalable pool fails if the confidence interval exceeds maximum permitted
57
- # 2.5%.
58
- set_tests_properties (
59
- ${BENCH_NAME} PROPERTIES
60
- LABELS "benchmark"
61
- PASS_REGULAR_EXPRESSION "PASSED" )
72
+ if ("${BENCH_NAME} " STREQUAL "umf-ubench" )
73
+ # Benchmark passes if it prints "PASSED" in the output, because ubench
74
+ # of scalable pool fails if the confidence interval exceeds maximum
75
+ # permitted 2.5%.
76
+ set_tests_properties (
77
+ ${BENCH_NAME} PROPERTIES
78
+ LABELS "benchmark"
79
+ PASS_REGULAR_EXPRESSION "PASSED" )
80
+ else ()
81
+ set_tests_properties (${BENCH_NAME} PROPERTIES LABELS "benchmark" )
82
+ endif ()
62
83
63
84
if (WINDOWS)
64
85
# append PATH to DLLs
@@ -68,19 +89,19 @@ function(add_umf_benchmark)
68
89
69
90
if (UMF_BUILD_LIBUMF_POOL_DISJOINT)
70
91
target_compile_definitions (${BENCH_NAME}
71
- PRIVATE UMF_BUILD_LIBUMF_POOL_DISJOINT =1)
92
+ PRIVATE UMF_POOL_DISJOINT_ENABLED =1)
72
93
endif ()
73
- if (UMF_BUILD_LIBUMF_POOL_JEMALLOC )
94
+ if (UMF_POOL_JEMALLOC_ENABLED )
74
95
target_compile_definitions (${BENCH_NAME}
75
- PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC =1)
96
+ PRIVATE UMF_POOL_JEMALLOC_ENABLED =1)
76
97
endif ()
77
98
if (UMF_POOL_SCALABLE_ENABLED)
78
99
target_compile_definitions (${BENCH_NAME}
79
100
PRIVATE UMF_POOL_SCALABLE_ENABLED=1)
80
101
endif ()
81
102
if (UMF_BUILD_LEVEL_ZERO_PROVIDER)
82
103
target_compile_definitions (${BENCH_NAME}
83
- PRIVATE UMF_BUILD_LEVEL_ZERO_PROVIDER =1)
104
+ PRIVATE UMF_PROVIDER_LEVEL_ZERO_ENABLED =1)
84
105
target_include_directories (
85
106
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR} /test /common
86
107
${LEVEL_ZERO_INCLUDE_DIRS} )
@@ -121,6 +142,12 @@ add_umf_benchmark(
121
142
LIBS ${LIBS_OPTIONAL}
122
143
LIBDIRS ${LIB_DIRS} )
123
144
145
+ add_umf_benchmark(
146
+ NAME benchmark
147
+ SRCS benchmark.cpp
148
+ LIBS ${LIBS_OPTIONAL} benchmark::benchmark
149
+ LIBDIRS ${LIB_DIRS} )
150
+
124
151
if (UMF_BUILD_BENCHMARKS_MT)
125
152
add_umf_benchmark(
126
153
NAME multithreaded
0 commit comments