diff options
author | 2023-08-08 14:07:40 -0700 | |
---|---|---|
committer | 2023-08-08 14:08:34 -0700 | |
commit | 298fd26156453f169bfb8eb6df0a12f8c06e82ae (patch) | |
tree | 5422f25f3a92261fc2e88b13903f56bc75ef0c63 /absl/time/civil_time_benchmark.cc | |
parent | a3c403f123050b9cf784dba6ba9578c9981847f5 (diff) |
Fix warnings:
* 'DoNotOptimize<T>' is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks
* missing #include <string> for 'std::string'
PiperOrigin-RevId: 554936149
Change-Id: Iaf06cd9b9b0762e3a514b7e1cfe4a4fd6df24083
Diffstat (limited to 'absl/time/civil_time_benchmark.cc')
-rw-r--r-- | absl/time/civil_time_benchmark.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/absl/time/civil_time_benchmark.cc b/absl/time/civil_time_benchmark.cc index f04dbe20..2de0233d 100644 --- a/absl/time/civil_time_benchmark.cc +++ b/absl/time/civil_time_benchmark.cc @@ -14,7 +14,9 @@ #include "absl/time/civil_time.h" +#include <cstddef> #include <numeric> +#include <string> #include <vector> #include "absl/hash/hash.h" @@ -42,7 +44,7 @@ void BM_Difference_Days(benchmark::State& state) { const absl::CivilDay c(2014, 8, 22); const absl::CivilDay epoch(1970, 1, 1); while (state.KeepRunning()) { - const absl::civil_diff_t n = c - epoch; + absl::civil_diff_t n = c - epoch; benchmark::DoNotOptimize(n); } } @@ -60,7 +62,7 @@ BENCHMARK(BM_Step_Days); void BM_Format(benchmark::State& state) { const absl::CivilSecond c(2014, 1, 2, 3, 4, 5); while (state.KeepRunning()) { - const std::string s = absl::FormatCivilTime(c); + std::string s = absl::FormatCivilTime(c); benchmark::DoNotOptimize(s); } } @@ -70,7 +72,7 @@ void BM_Parse(benchmark::State& state) { const std::string f = "2014-01-02T03:04:05"; absl::CivilSecond c; while (state.KeepRunning()) { - const bool b = absl::ParseCivilTime(f, &c); + bool b = absl::ParseCivilTime(f, &c); benchmark::DoNotOptimize(b); } } @@ -80,7 +82,7 @@ void BM_RoundTripFormatParse(benchmark::State& state) { const absl::CivilSecond c(2014, 1, 2, 3, 4, 5); absl::CivilSecond out; while (state.KeepRunning()) { - const bool b = absl::ParseCivilTime(absl::FormatCivilTime(c), &out); + bool b = absl::ParseCivilTime(absl::FormatCivilTime(c), &out); benchmark::DoNotOptimize(b); } } @@ -95,7 +97,8 @@ void BM_CivilTimeAbslHash(benchmark::State& state) { absl::Hash<T> absl_hasher; while (state.KeepRunningBatch(kSize)) { for (const T civil_time : civil_times) { - benchmark::DoNotOptimize(absl_hasher(civil_time)); + size_t hash = absl_hasher(civil_time); + benchmark::DoNotOptimize(hash); } } } |