diff options
Diffstat (limited to 'absl/time/civil_time_benchmark.cc')
-rw-r--r-- | absl/time/civil_time_benchmark.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/absl/time/civil_time_benchmark.cc b/absl/time/civil_time_benchmark.cc index 40869835b714..f04dbe200ed2 100644 --- a/absl/time/civil_time_benchmark.cc +++ b/absl/time/civil_time_benchmark.cc @@ -66,6 +66,26 @@ void BM_Format(benchmark::State& state) { } BENCHMARK(BM_Format); +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); + benchmark::DoNotOptimize(b); + } +} +BENCHMARK(BM_Parse); + +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); + benchmark::DoNotOptimize(b); + } +} +BENCHMARK(BM_RoundTripFormatParse); + template <typename T> void BM_CivilTimeAbslHash(benchmark::State& state) { const int kSize = 100000; |