summaryrefslogtreecommitdiff
path: root/absl/time/civil_time_benchmark.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2019-09-20 07:07:04 -0700
committerGravatar Shaindel Schwartz <shaindel@google.com>2019-09-20 10:40:36 -0400
commitccdd1d57b6386ebc26fb0c7d99b604672437c124 (patch)
treebd2b466cbcf92fe15b5a6cd88a03ed8bdba33af7 /absl/time/civil_time_benchmark.cc
parentddf8e52a2918dd0ccec75d3e2426125fa3926724 (diff)
Export of internal Abseil changes
-- 509c39cb5aa70893a180e5625e06cd9f76061ecf by Shaindel Schwartz <shaindel@google.com>: Release CivilTime parsing API. PiperOrigin-RevId: 270262448 GitOrigin-RevId: 509c39cb5aa70893a180e5625e06cd9f76061ecf Change-Id: I343eb3062cdf6a2c53e6fddcaa35eb25d7478b1a
Diffstat (limited to 'absl/time/civil_time_benchmark.cc')
-rw-r--r--absl/time/civil_time_benchmark.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/absl/time/civil_time_benchmark.cc b/absl/time/civil_time_benchmark.cc
index 40869835..f04dbe20 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;