diff options
author | thegeorg <thegeorg@yandex-team.com> | 2023-07-17 18:21:42 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2023-07-17 18:21:42 +0300 |
commit | b5cf42727a51c60ab7cbca31253756dec5cdac23 (patch) | |
tree | 63c87f128cac15b770e44964c3e1f03555ca2fcb /contrib | |
parent | 0e636597924f0fa87bfc61c7f65b572d42e96ed1 (diff) | |
download | ydb-b5cf42727a51c60ab7cbca31253756dec5cdac23.tar.gz |
Update contrib/restricted/google/benchmark to 1.8.2
Diffstat (limited to 'contrib')
7 files changed, 60 insertions, 23 deletions
diff --git a/contrib/restricted/google/benchmark/README.md b/contrib/restricted/google/benchmark/README.md index b64048b7d3..a5e5d392d8 100644 --- a/contrib/restricted/google/benchmark/README.md +++ b/contrib/restricted/google/benchmark/README.md @@ -4,10 +4,9 @@ [![bazel](https://github.com/google/benchmark/actions/workflows/bazel.yml/badge.svg)](https://github.com/google/benchmark/actions/workflows/bazel.yml) [![pylint](https://github.com/google/benchmark/workflows/pylint/badge.svg)](https://github.com/google/benchmark/actions?query=workflow%3Apylint) [![test-bindings](https://github.com/google/benchmark/workflows/test-bindings/badge.svg)](https://github.com/google/benchmark/actions?query=workflow%3Atest-bindings) - -[![Build Status](https://travis-ci.org/google/benchmark.svg?branch=main)](https://travis-ci.org/google/benchmark) [![Coverage Status](https://coveralls.io/repos/google/benchmark/badge.svg)](https://coveralls.io/r/google/benchmark) +[![Discord](https://discordapp.com/api/guilds/1125694995928719494/widget.png?style=shield)](https://discord.gg/cz7UX7wKC2) A library to benchmark code snippets, similar to unit tests. Example: diff --git a/contrib/restricted/google/benchmark/include/benchmark/benchmark.h b/contrib/restricted/google/benchmark/include/benchmark/benchmark.h index 4a8be19d86..d53d761ad8 100644 --- a/contrib/restricted/google/benchmark/include/benchmark/benchmark.h +++ b/contrib/restricted/google/benchmark/include/benchmark/benchmark.h @@ -465,19 +465,24 @@ inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { } template <class Tp> -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize( -#ifdef BENCHMARK_HAS_CXX11 - Tp&& value +inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { +#if defined(__clang__) + asm volatile("" : "+r,m"(value) : : "memory"); #else - Tp& value + asm volatile("" : "+m,r"(value) : : "memory"); #endif -) { +} + +#ifdef BENCHMARK_HAS_CXX11 +template <class Tp> +inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp&& value) { #if defined(__clang__) asm volatile("" : "+r,m"(value) : : "memory"); #else asm volatile("" : "+m,r"(value) : : "memory"); #endif } +#endif #elif defined(BENCHMARK_HAS_CXX11) && (__GNUC__ >= 5) // Workaround for a bug with full argument copy overhead with GCC. // See: #1340 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105519 @@ -507,6 +512,22 @@ template <class Tp> inline BENCHMARK_ALWAYS_INLINE typename std::enable_if<std::is_trivially_copyable<Tp>::value && (sizeof(Tp) <= sizeof(Tp*))>::type + DoNotOptimize(Tp& value) { + asm volatile("" : "+m,r"(value) : : "memory"); +} + +template <class Tp> +inline BENCHMARK_ALWAYS_INLINE + typename std::enable_if<!std::is_trivially_copyable<Tp>::value || + (sizeof(Tp) > sizeof(Tp*))>::type + DoNotOptimize(Tp& value) { + asm volatile("" : "+m"(value) : : "memory"); +} + +template <class Tp> +inline BENCHMARK_ALWAYS_INLINE + typename std::enable_if<std::is_trivially_copyable<Tp>::value && + (sizeof(Tp) <= sizeof(Tp*))>::type DoNotOptimize(Tp&& value) { asm volatile("" : "+m,r"(value) : : "memory"); } @@ -532,16 +553,17 @@ inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { } template <class Tp> -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize( +inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { + asm volatile("" : "+m"(value) : : "memory"); +} + #ifdef BENCHMARK_HAS_CXX11 - Tp&& value -#else - Tp& value -#endif -) { +template <class Tp> +inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp&& value) { asm volatile("" : "+m"(value) : : "memory"); } #endif +#endif #ifndef BENCHMARK_HAS_CXX11 inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { @@ -1362,6 +1384,8 @@ class LambdaBenchmark : public Benchmark { inline internal::Benchmark* RegisterBenchmark(const std::string& name, internal::Function* fn) { + // FIXME: this should be a `std::make_unique<>()` but we don't have C++14. + // codechecker_intentional [cplusplus.NewDeleteLeaks] return internal::RegisterBenchmarkInternal( ::new internal::FunctionBenchmark(name, fn)); } @@ -1371,6 +1395,8 @@ template <class Lambda> internal::Benchmark* RegisterBenchmark(const std::string& name, Lambda&& fn) { using BenchType = internal::LambdaBenchmark<typename std::decay<Lambda>::type>; + // FIXME: this should be a `std::make_unique<>()` but we don't have C++14. + // codechecker_intentional [cplusplus.NewDeleteLeaks] return internal::RegisterBenchmarkInternal( ::new BenchType(name, std::forward<Lambda>(fn))); } diff --git a/contrib/restricted/google/benchmark/src/benchmark.cc b/contrib/restricted/google/benchmark/src/benchmark.cc index f1633b703f..7fb1740af3 100644 --- a/contrib/restricted/google/benchmark/src/benchmark.cc +++ b/contrib/restricted/google/benchmark/src/benchmark.cc @@ -229,7 +229,7 @@ void State::PauseTiming() { for (const auto& name_and_measurement : measurements) { auto name = name_and_measurement.first; auto measurement = name_and_measurement.second; - BM_CHECK_EQ(std::fpclassify((double)counters[name]), FP_ZERO); + BM_CHECK_EQ(std::fpclassify(double{counters[name]}), FP_ZERO); counters[name] = Counter(measurement, Counter::kAvgIterations); } } diff --git a/contrib/restricted/google/benchmark/src/colorprint.cc b/contrib/restricted/google/benchmark/src/colorprint.cc index 9a653c5007..0bfd67041d 100644 --- a/contrib/restricted/google/benchmark/src/colorprint.cc +++ b/contrib/restricted/google/benchmark/src/colorprint.cc @@ -163,12 +163,24 @@ bool IsColorTerminal() { #else // On non-Windows platforms, we rely on the TERM variable. This list of // supported TERM values is copied from Google Test: - // <https://github.com/google/googletest/blob/main/googletest/src/gtest.cc#L2925>. + // <https://github.com/google/googletest/blob/v1.13.0/googletest/src/gtest.cc#L3225-L3259>. const char* const SUPPORTED_TERM_VALUES[] = { - "xterm", "xterm-color", "xterm-256color", - "screen", "screen-256color", "tmux", - "tmux-256color", "rxvt-unicode", "rxvt-unicode-256color", - "linux", "cygwin", + "xterm", + "xterm-color", + "xterm-256color", + "screen", + "screen-256color", + "tmux", + "tmux-256color", + "rxvt-unicode", + "rxvt-unicode-256color", + "linux", + "cygwin", + "xterm-kitty", + "alacritty", + "foot", + "foot-extra", + "wezterm", }; const char* const term = getenv("TERM"); diff --git a/contrib/restricted/google/benchmark/src/log.h b/contrib/restricted/google/benchmark/src/log.h index 45701667a2..9a21400b09 100644 --- a/contrib/restricted/google/benchmark/src/log.h +++ b/contrib/restricted/google/benchmark/src/log.h @@ -61,7 +61,7 @@ inline int& LogLevel() { } inline LogType& GetNullLogInstance() { - static LogType null_log((std::ostream*)nullptr); + static LogType null_log(static_cast<std::ostream*>(nullptr)); return null_log; } diff --git a/contrib/restricted/google/benchmark/src/re.h b/contrib/restricted/google/benchmark/src/re.h index 630046782d..9afb869bea 100644 --- a/contrib/restricted/google/benchmark/src/re.h +++ b/contrib/restricted/google/benchmark/src/re.h @@ -33,7 +33,7 @@ // Prefer C regex libraries when compiling w/o exceptions so that we can // correctly report errors. #if defined(BENCHMARK_HAS_NO_EXCEPTIONS) && \ - defined(BENCHMARK_HAVE_STD_REGEX) && \ + defined(HAVE_STD_REGEX) && \ (defined(HAVE_GNU_POSIX_REGEX) || defined(HAVE_POSIX_REGEX)) #undef HAVE_STD_REGEX #endif diff --git a/contrib/restricted/google/benchmark/ya.make b/contrib/restricted/google/benchmark/ya.make index 886e082a5b..c3e8191cea 100644 --- a/contrib/restricted/google/benchmark/ya.make +++ b/contrib/restricted/google/benchmark/ya.make @@ -6,9 +6,9 @@ LICENSE(Apache-2.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.8.0) +VERSION(1.8.2) -ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.8.0.tar.gz) +ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.8.2.tar.gz) ADDINCL( GLOBAL contrib/restricted/google/benchmark/include |