Skip to content

Commit 2e93ee6

Browse files
authored
Update Benchmark (#83488)
Addresses the `third-party/benchmark` part of #81859 (by happening to remove `requirements.txt`)
1 parent e10dc60 commit 2e93ee6

File tree

107 files changed

+3773
-1622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3773
-1622
lines changed

third-party/benchmark/.ycm_extra_conf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
import ycm_core
34

45
# These are the compilation flags that will be used in case there's no
@@ -91,7 +92,9 @@ def GetCompilationInfoForFile(filename):
9192
for extension in SOURCE_EXTENSIONS:
9293
replacement_file = basename + extension
9394
if os.path.exists(replacement_file):
94-
compilation_info = database.GetCompilationInfoForFile(replacement_file)
95+
compilation_info = database.GetCompilationInfoForFile(
96+
replacement_file
97+
)
9598
if compilation_info.compiler_flags_:
9699
return compilation_info
97100
return None
@@ -107,7 +110,8 @@ def FlagsForFile(filename, **kwargs):
107110
return None
108111

109112
final_flags = MakeRelativePathsInFlagsAbsolute(
110-
compilation_info.compiler_flags_, compilation_info.compiler_working_dir_
113+
compilation_info.compiler_flags_,
114+
compilation_info.compiler_working_dir_,
111115
)
112116
else:
113117
relative_to = DirectoryOfThisScript()

third-party/benchmark/AUTHORS

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Alex Steele <[email protected]>
1313
Andriy Berestovskyy <[email protected]>
1414
Arne Beer <[email protected]>
1515
Carto
16+
Cezary Skrzyński <[email protected]>
1617
Christian Wassermann <[email protected]>
1718
Christopher Seymour <[email protected]>
1819
Colin Braley <[email protected]>
@@ -27,10 +28,13 @@ Eric Backus <[email protected]>
2728
Eric Fiselier <[email protected]>
2829
Eugene Zhuk <[email protected]>
2930
Evgeny Safronov <[email protected]>
31+
Fabien Pichot <[email protected]>
3032
Federico Ficarelli <[email protected]>
3133
Felix Homann <[email protected]>
34+
Gergely Meszaros <[email protected]>
3235
Gergő Szitár <[email protected]>
3336
Google Inc.
37+
Henrique Bucher <[email protected]>
3438
International Business Machines Corporation
3539
Ismael Jimenez Martinez <[email protected]>
3640
Jern-Kuan Leong <[email protected]>
@@ -41,22 +45,28 @@ Jussi Knuuttila <[email protected]>
4145
Kaito Udagawa <[email protected]>
4246
Kishan Kumar <[email protected]>
4347
48+
Marcel Jacobse <[email protected]>
4449
Matt Clarkson <[email protected]>
4550
Maxim Vafin <[email protected]>
51+
Mike Apodaca <[email protected]>
52+
Min-Yih Hsu <[email protected]>
4653
MongoDB Inc.
4754
Nick Hutchinson <[email protected]>
4855
Norman Heino <[email protected]>
4956
Oleksandr Sochka <[email protected]>
5057
Ori Livneh <[email protected]>
5158
Paul Redmond <[email protected]>
5259
Radoslav Yovchev <[email protected]>
60+
Raghu Raja <[email protected]>
61+
Rainer Orth <[email protected]>
5362
Roman Lebedev <[email protected]>
5463
Sayan Bhattacharjee <[email protected]>
64+
5565
Shuo Chen <[email protected]>
66+
Staffan Tjernstrom <[email protected]>
5667
Steinar H. Gunderson <[email protected]>
5768
Stripe, Inc.
5869
Tobias Schmidt <[email protected]>
5970
Yixuan Qiu <[email protected]>
6071
Yusuke Suzuki <[email protected]>
6172
Zbigniew Skowron <[email protected]>
62-
Min-Yih Hsu <[email protected]>

third-party/benchmark/CMakeLists.txt

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
cmake_minimum_required (VERSION 3.5.1)
2-
3-
foreach(p
4-
CMP0048 # OK to clear PROJECT_VERSION on project()
5-
CMP0054 # CMake 3.1
6-
CMP0056 # export EXE_LINKER_FLAGS to try_run
7-
CMP0057 # Support no if() IN_LIST operator
8-
CMP0063 # Honor visibility properties for all targets
9-
CMP0077 # Allow option() overrides in importing projects
10-
)
11-
if(POLICY ${p})
12-
cmake_policy(SET ${p} NEW)
13-
endif()
14-
endforeach()
1+
# Require CMake 3.10. If available, use the policies up to CMake 3.22.
2+
cmake_minimum_required (VERSION 3.10...3.22)
153

16-
project (benchmark VERSION 1.6.0 LANGUAGES CXX)
4+
project (benchmark VERSION 1.8.3 LANGUAGES CXX)
175

186
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
197
option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
@@ -26,11 +14,14 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
2614
# PGC++ maybe reporting false positives.
2715
set(BENCHMARK_ENABLE_WERROR OFF)
2816
endif()
17+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "NVHPC")
18+
set(BENCHMARK_ENABLE_WERROR OFF)
19+
endif()
2920
if(BENCHMARK_FORCE_WERROR)
3021
set(BENCHMARK_ENABLE_WERROR ON)
3122
endif(BENCHMARK_FORCE_WERROR)
3223

33-
if(NOT MSVC)
24+
if(NOT (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
3425
option(BENCHMARK_BUILD_32_BITS "Build a 32 bit version of the library." OFF)
3526
else()
3627
set(BENCHMARK_BUILD_32_BITS OFF CACHE BOOL "Build a 32 bit version of the library - unsupported when using MSVC)" FORCE)
@@ -50,8 +41,11 @@ option(BENCHMARK_USE_BUNDLED_GTEST "Use bundled GoogleTest. If disabled, the fin
5041

5142
option(BENCHMARK_ENABLE_LIBPFM "Enable performance counters provided by libpfm" OFF)
5243

53-
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
54-
if(MSVC)
44+
# Export only public symbols
45+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
46+
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
47+
48+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
5549
# As of CMake 3.18, CMAKE_SYSTEM_PROCESSOR is not set properly for MSVC and
5650
# cross-compilation (e.g. Host=x86_64, target=aarch64) requires using the
5751
# undocumented, but working variable.
@@ -72,7 +66,7 @@ function(should_enable_assembly_tests)
7266
return()
7367
endif()
7468
endif()
75-
if (MSVC)
69+
if (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
7670
return()
7771
elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
7872
return()
@@ -111,29 +105,49 @@ get_git_version(GIT_VERSION)
111105
# If no git version can be determined, use the version
112106
# from the project() command
113107
if ("${GIT_VERSION}" STREQUAL "0.0.0")
114-
set(VERSION "${benchmark_VERSION}")
108+
set(VERSION "v${benchmark_VERSION}")
115109
else()
116110
set(VERSION "${GIT_VERSION}")
117111
endif()
112+
113+
# Normalize version: drop "v" prefix, replace first "-" with ".",
114+
# drop everything after second "-" (including said "-").
115+
string(STRIP ${VERSION} VERSION)
116+
if(VERSION MATCHES v[^-]*-)
117+
string(REGEX REPLACE "v([^-]*)-([0-9]+)-.*" "\\1.\\2" NORMALIZED_VERSION ${VERSION})
118+
else()
119+
string(REGEX REPLACE "v(.*)" "\\1" NORMALIZED_VERSION ${VERSION})
120+
endif()
121+
118122
# Tell the user what versions we are using
119-
message(STATUS "Version: ${VERSION}")
123+
message(STATUS "Google Benchmark version: ${VERSION}, normalized to ${NORMALIZED_VERSION}")
120124

121125
# The version of the libraries
122-
set(GENERIC_LIB_VERSION ${VERSION})
123-
string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION)
126+
set(GENERIC_LIB_VERSION ${NORMALIZED_VERSION})
127+
string(SUBSTRING ${NORMALIZED_VERSION} 0 1 GENERIC_LIB_SOVERSION)
124128

125129
# Import our CMake modules
126-
include(CheckCXXCompilerFlag)
127130
include(AddCXXCompilerFlag)
128-
include(CXXFeatureCheck)
131+
include(CheckCXXCompilerFlag)
129132
include(CheckLibraryExists)
133+
include(CXXFeatureCheck)
130134

131135
check_library_exists(rt shm_open "" HAVE_LIB_RT)
132136

133137
if (BENCHMARK_BUILD_32_BITS)
134138
add_required_cxx_compiler_flag(-m32)
135139
endif()
136140

141+
if (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
142+
set(BENCHMARK_CXX_STANDARD 14)
143+
else()
144+
set(BENCHMARK_CXX_STANDARD 11)
145+
endif()
146+
147+
set(CMAKE_CXX_STANDARD ${BENCHMARK_CXX_STANDARD})
148+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
149+
set(CMAKE_CXX_EXTENSIONS OFF)
150+
137151
if (MSVC)
138152
# Turn compiler warnings up to 11
139153
string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@@ -166,21 +180,18 @@ if (MSVC)
166180
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG")
167181
endif()
168182
else()
169-
# Try and enable C++11. Don't use C++14 because it doesn't work in some
170-
# configurations.
171-
add_cxx_compiler_flag(-std=c++11)
172-
if (NOT HAVE_CXX_FLAG_STD_CXX11)
173-
add_cxx_compiler_flag(-std=c++0x)
174-
endif()
175-
183+
# Turn on Large-file Support
184+
add_definitions(-D_FILE_OFFSET_BITS=64)
185+
add_definitions(-D_LARGEFILE64_SOURCE)
186+
add_definitions(-D_LARGEFILE_SOURCE)
176187
# Turn compiler warnings up to 11
177188
add_cxx_compiler_flag(-Wall)
178189
add_cxx_compiler_flag(-Wextra)
179190
add_cxx_compiler_flag(-Wshadow)
191+
add_cxx_compiler_flag(-Wfloat-equal)
192+
add_cxx_compiler_flag(-Wold-style-cast)
180193
if(BENCHMARK_ENABLE_WERROR)
181-
add_cxx_compiler_flag(-Werror RELEASE)
182-
add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
183-
add_cxx_compiler_flag(-Werror MINSIZEREL)
194+
add_cxx_compiler_flag(-Werror)
184195
endif()
185196
if (NOT BENCHMARK_ENABLE_TESTING)
186197
# Disable warning when compiling tests as gtest does not use 'override'.
@@ -193,24 +204,23 @@ else()
193204
# Disable warnings regarding deprecated parts of the library while building
194205
# and testing those parts of the library.
195206
add_cxx_compiler_flag(-Wno-deprecated-declarations)
196-
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
207+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
197208
# Intel silently ignores '-Wno-deprecated-declarations',
198209
# warning no. 1786 must be explicitly disabled.
199210
# See #631 for rationale.
200211
add_cxx_compiler_flag(-wd1786)
212+
add_cxx_compiler_flag(-fno-finite-math-only)
201213
endif()
202214
# Disable deprecation warnings for release builds (when -Werror is enabled).
203215
if(BENCHMARK_ENABLE_WERROR)
204-
add_cxx_compiler_flag(-Wno-deprecated RELEASE)
205-
add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO)
206-
add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL)
216+
add_cxx_compiler_flag(-Wno-deprecated)
207217
endif()
208218
if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
209219
add_cxx_compiler_flag(-fno-exceptions)
210220
endif()
211221

212222
if (HAVE_CXX_FLAG_FSTRICT_ALIASING)
213-
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing
223+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") #ICC17u2: Many false positives for Wstrict-aliasing
214224
add_cxx_compiler_flag(-Wstrict-aliasing)
215225
endif()
216226
endif()
@@ -219,12 +229,12 @@ else()
219229
add_cxx_compiler_flag(-wd654)
220230
add_cxx_compiler_flag(-Wthread-safety)
221231
if (HAVE_CXX_FLAG_WTHREAD_SAFETY)
222-
cxx_feature_check(THREAD_SAFETY_ATTRIBUTES)
232+
cxx_feature_check(THREAD_SAFETY_ATTRIBUTES "-DINCLUDE_DIRECTORIES=${PROJECT_SOURCE_DIR}/include")
223233
endif()
224234

225235
# On most UNIX like platforms g++ and clang++ define _GNU_SOURCE as a
226236
# predefined macro, which turns on all of the wonderful libc extensions.
227-
# However g++ doesn't do this in Cygwin so we have to define it ourselfs
237+
# However g++ doesn't do this in Cygwin so we have to define it ourselves
228238
# since we depend on GNU/POSIX/BSD extensions.
229239
if (CYGWIN)
230240
add_definitions(-D_GNU_SOURCE=1)
@@ -275,7 +285,8 @@ if (BENCHMARK_USE_LIBCXX)
275285
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
276286
add_cxx_compiler_flag(-stdlib=libc++)
277287
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
278-
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
288+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" OR
289+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM")
279290
add_cxx_compiler_flag(-nostdinc++)
280291
message(WARNING "libc++ header path must be manually specified using CMAKE_CXX_FLAGS")
281292
# Adding -nodefaultlibs directly to CMAKE_<TYPE>_LINKER_FLAGS will break
@@ -312,9 +323,10 @@ cxx_feature_check(STEADY_CLOCK)
312323
# Ensure we have pthreads
313324
set(THREADS_PREFER_PTHREAD_FLAG ON)
314325
find_package(Threads REQUIRED)
326+
cxx_feature_check(PTHREAD_AFFINITY)
315327

316328
if (BENCHMARK_ENABLE_LIBPFM)
317-
find_package(PFM)
329+
find_package(PFM REQUIRED)
318330
endif()
319331

320332
# Set up directories

third-party/benchmark/CONTRIBUTORS

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Albert Pretorius <[email protected]>
2727
Alex Steele <[email protected]>
2828
Andriy Berestovskyy <[email protected]>
2929
Arne Beer <[email protected]>
30+
Bátor Tallér <[email protected]>
3031
Billy Robert O'Neal III <[email protected]> <[email protected]>
32+
Cezary Skrzyński <[email protected]>
3133
3234
Christian Wassermann <[email protected]>
3335
Christopher Seymour <[email protected]>
@@ -44,25 +46,32 @@ Eric Backus <[email protected]>
4446
Eric Fiselier <[email protected]>
4547
Eugene Zhuk <[email protected]>
4648
Evgeny Safronov <[email protected]>
49+
Fabien Pichot <[email protected]>
4750
Fanbo Meng <[email protected]>
4851
Federico Ficarelli <[email protected]>
4952
Felix Homann <[email protected]>
5053
Geoffrey Martin-Noble <[email protected]> <[email protected]>
54+
Gergely Meszaros <[email protected]>
5155
Gergő Szitár <[email protected]>
5256
Hannes Hauswedell <[email protected]>
57+
Henrique Bucher <[email protected]>
5358
Ismael Jimenez Martinez <[email protected]>
59+
Iakov Sergeev <[email protected]>
5460
Jern-Kuan Leong <[email protected]>
5561
JianXiong Zhou <[email protected]>
5662
Joao Paulo Magalhaes <[email protected]>
5763
John Millikin <[email protected]>
5864
Jordan Williams <[email protected]>
5965
Jussi Knuuttila <[email protected]>
60-
6166
Kaito Udagawa <[email protected]>
67+
6268
Kishan Kumar <[email protected]>
6369
70+
Marcel Jacobse <[email protected]>
6471
Matt Clarkson <[email protected]>
6572
Maxim Vafin <[email protected]>
73+
Mike Apodaca <[email protected]>
74+
Min-Yih Hsu <[email protected]>
6675
Nick Hutchinson <[email protected]>
6776
Norman Heino <[email protected]>
6877
Oleksandr Sochka <[email protected]>
@@ -71,6 +80,8 @@ Pascal Leroy <[email protected]>
7180
Paul Redmond <[email protected]>
7281
Pierre Phaneuf <[email protected]>
7382
Radoslav Yovchev <[email protected]>
83+
Raghu Raja <[email protected]>
84+
Rainer Orth <[email protected]>
7485
Raul Marin <[email protected]>
7586
Ray Glover <[email protected]>
7687
Robert Guo <[email protected]>
@@ -84,4 +95,3 @@ Tom Madams <[email protected]> <[email protected]>
8495
Yixuan Qiu <[email protected]>
8596
Yusuke Suzuki <[email protected]>
8697
Zbigniew Skowron <[email protected]>
87-
Min-Yih Hsu <[email protected]>

third-party/benchmark/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
[![bazel](https://github.com/google/benchmark/actions/workflows/bazel.yml/badge.svg)](https://github.com/google/benchmark/actions/workflows/bazel.yml)
55
[![pylint](https://github.com/google/benchmark/workflows/pylint/badge.svg)](https://github.com/google/benchmark/actions?query=workflow%3Apylint)
66
[![test-bindings](https://github.com/google/benchmark/workflows/test-bindings/badge.svg)](https://github.com/google/benchmark/actions?query=workflow%3Atest-bindings)
7-
8-
[![Build Status](https://travis-ci.org/google/benchmark.svg?branch=master)](https://travis-ci.org/google/benchmark)
97
[![Coverage Status](https://coveralls.io/repos/google/benchmark/badge.svg)](https://coveralls.io/r/google/benchmark)
108

9+
[![Discord](https://discordapp.com/api/guilds/1125694995928719494/widget.png?style=shield)](https://discord.gg/cz7UX7wKC2)
1110

1211
A library to benchmark code snippets, similar to unit tests. Example:
1312

@@ -33,7 +32,7 @@ To get started, see [Requirements](#requirements) and
3332
[Installation](#installation). See [Usage](#usage) for a full example and the
3433
[User Guide](docs/user_guide.md) for a more comprehensive feature overview.
3534
36-
It may also help to read the [Google Test documentation](https://github.com/google/googletest/blob/master/docs/primer.md)
35+
It may also help to read the [Google Test documentation](https://github.com/google/googletest/blob/main/docs/primer.md)
3736
as some of the structural aspects of the APIs are similar.
3837
3938
## Resources
@@ -47,6 +46,8 @@ IRC channels:
4746
4847
[Assembly Testing Documentation](docs/AssemblyTests.md)
4948
49+
[Building and installing Python bindings](docs/python_bindings.md)
50+
5051
## Requirements
5152
5253
The library can be used with C++03. However, it requires C++11 to build,
@@ -137,6 +138,12 @@ cache variables, if autodetection fails.
137138
If you are using clang, you may need to set `LLVMAR_EXECUTABLE`,
138139
`LLVMNM_EXECUTABLE` and `LLVMRANLIB_EXECUTABLE` cmake cache variables.
139140

141+
To enable sanitizer checks (eg., `asan` and `tsan`), add:
142+
```
143+
-DCMAKE_C_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=address -fsanitize=thread -fno-sanitize-recover=all"
144+
-DCMAKE_CXX_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=address -fsanitize=thread -fno-sanitize-recover=all "
145+
```
146+
140147
### Stable and Experimental Library Versions
141148

142149
The main branch contains the latest stable version of the benchmarking library;

0 commit comments

Comments
 (0)