summaryrefslogtreecommitdiff
path: root/absl/time/internal/cctz/src/cctz_benchmark.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/time/internal/cctz/src/cctz_benchmark.cc')
-rw-r--r--absl/time/internal/cctz/src/cctz_benchmark.cc64
1 files changed, 31 insertions, 33 deletions
diff --git a/absl/time/internal/cctz/src/cctz_benchmark.cc b/absl/time/internal/cctz/src/cctz_benchmark.cc
index f13cb4ee..4498d7d0 100644
--- a/absl/time/internal/cctz/src/cctz_benchmark.cc
+++ b/absl/time/internal/cctz/src/cctz_benchmark.cc
@@ -754,23 +754,21 @@ void BM_Zone_LoadAllTimeZonesCached(benchmark::State& state) {
}
BENCHMARK(BM_Zone_LoadAllTimeZonesCached);
-void BM_Zone_TimeZoneImplGetImplicit(benchmark::State& state) {
+void BM_Zone_TimeZoneEqualityImplicit(benchmark::State& state) {
cctz::time_zone tz; // implicit UTC
- cctz::time_zone::Impl::get(tz);
while (state.KeepRunning()) {
- cctz::time_zone::Impl::get(tz);
+ benchmark::DoNotOptimize(tz == tz);
}
}
-BENCHMARK(BM_Zone_TimeZoneImplGetImplicit);
+BENCHMARK(BM_Zone_TimeZoneEqualityImplicit);
-void BM_Zone_TimeZoneImplGetExplicit(benchmark::State& state) {
+void BM_Zone_TimeZoneEqualityExplicit(benchmark::State& state) {
cctz::time_zone tz = cctz::utc_time_zone(); // explicit UTC
- cctz::time_zone::Impl::get(tz);
while (state.KeepRunning()) {
- cctz::time_zone::Impl::get(tz);
+ benchmark::DoNotOptimize(tz == tz);
}
}
-BENCHMARK(BM_Zone_TimeZoneImplGetExplicit);
+BENCHMARK(BM_Zone_TimeZoneEqualityExplicit);
void BM_Zone_UTCTimeZone(benchmark::State& state) {
cctz::time_zone tz;
@@ -780,13 +778,13 @@ void BM_Zone_UTCTimeZone(benchmark::State& state) {
}
BENCHMARK(BM_Zone_UTCTimeZone);
-// In each "ToDateTime" benchmark we switch between two instants
-// separated by at least one transition in order to defeat any
-// internal caching of previous results (e.g., see local_time_hint_).
+// In each "ToCivil" benchmark we switch between two instants separated
+// by at least one transition in order to defeat any internal caching of
+// previous results (e.g., see local_time_hint_).
//
// The "UTC" variants use UTC instead of the Google/local time zone.
-void BM_Time_ToDateTime_CCTZ(benchmark::State& state) {
+void BM_Time_ToCivil_CCTZ(benchmark::State& state) {
const cctz::time_zone tz = TestTimeZone();
std::chrono::system_clock::time_point tp =
std::chrono::system_clock::from_time_t(1384569027);
@@ -798,9 +796,9 @@ void BM_Time_ToDateTime_CCTZ(benchmark::State& state) {
benchmark::DoNotOptimize(cctz::convert(tp, tz));
}
}
-BENCHMARK(BM_Time_ToDateTime_CCTZ);
+BENCHMARK(BM_Time_ToCivil_CCTZ);
-void BM_Time_ToDateTime_Libc(benchmark::State& state) {
+void BM_Time_ToCivil_Libc(benchmark::State& state) {
// No timezone support, so just use localtime.
time_t t = 1384569027;
time_t t2 = 1418962578;
@@ -815,9 +813,9 @@ void BM_Time_ToDateTime_Libc(benchmark::State& state) {
#endif
}
}
-BENCHMARK(BM_Time_ToDateTime_Libc);
+BENCHMARK(BM_Time_ToCivil_Libc);
-void BM_Time_ToDateTimeUTC_CCTZ(benchmark::State& state) {
+void BM_Time_ToCivilUTC_CCTZ(benchmark::State& state) {
const cctz::time_zone tz = cctz::utc_time_zone();
std::chrono::system_clock::time_point tp =
std::chrono::system_clock::from_time_t(1384569027);
@@ -826,9 +824,9 @@ void BM_Time_ToDateTimeUTC_CCTZ(benchmark::State& state) {
benchmark::DoNotOptimize(cctz::convert(tp, tz));
}
}
-BENCHMARK(BM_Time_ToDateTimeUTC_CCTZ);
+BENCHMARK(BM_Time_ToCivilUTC_CCTZ);
-void BM_Time_ToDateTimeUTC_Libc(benchmark::State& state) {
+void BM_Time_ToCivilUTC_Libc(benchmark::State& state) {
time_t t = 1384569027;
struct tm tm;
while (state.KeepRunning()) {
@@ -840,16 +838,16 @@ void BM_Time_ToDateTimeUTC_Libc(benchmark::State& state) {
#endif
}
}
-BENCHMARK(BM_Time_ToDateTimeUTC_Libc);
+BENCHMARK(BM_Time_ToCivilUTC_Libc);
-// In each "FromDateTime" benchmark we switch between two YMDhms
-// values separated by at least one transition in order to defeat any
-// internal caching of previous results (e.g., see time_local_hint_).
+// In each "FromCivil" benchmark we switch between two YMDhms values
+// separated by at least one transition in order to defeat any internal
+// caching of previous results (e.g., see time_local_hint_).
//
// The "UTC" variants use UTC instead of the Google/local time zone.
// The "Day0" variants require normalization of the day of month.
-void BM_Time_FromDateTime_CCTZ(benchmark::State& state) {
+void BM_Time_FromCivil_CCTZ(benchmark::State& state) {
const cctz::time_zone tz = TestTimeZone();
int i = 0;
while (state.KeepRunning()) {
@@ -862,9 +860,9 @@ void BM_Time_FromDateTime_CCTZ(benchmark::State& state) {
}
}
}
-BENCHMARK(BM_Time_FromDateTime_CCTZ);
+BENCHMARK(BM_Time_FromCivil_CCTZ);
-void BM_Time_FromDateTime_Libc(benchmark::State& state) {
+void BM_Time_FromCivil_Libc(benchmark::State& state) {
// No timezone support, so just use localtime.
int i = 0;
while (state.KeepRunning()) {
@@ -888,20 +886,20 @@ void BM_Time_FromDateTime_Libc(benchmark::State& state) {
benchmark::DoNotOptimize(mktime(&tm));
}
}
-BENCHMARK(BM_Time_FromDateTime_Libc);
+BENCHMARK(BM_Time_FromCivil_Libc);
-void BM_Time_FromDateTimeUTC_CCTZ(benchmark::State& state) {
+void BM_Time_FromCivilUTC_CCTZ(benchmark::State& state) {
const cctz::time_zone tz = cctz::utc_time_zone();
while (state.KeepRunning()) {
benchmark::DoNotOptimize(
cctz::convert(cctz::civil_second(2014, 12, 18, 20, 16, 18), tz));
}
}
-BENCHMARK(BM_Time_FromDateTimeUTC_CCTZ);
+BENCHMARK(BM_Time_FromCivilUTC_CCTZ);
-// There is no BM_Time_FromDateTimeUTC_Libc.
+// There is no BM_Time_FromCivilUTC_Libc.
-void BM_Time_FromDateTimeDay0_CCTZ(benchmark::State& state) {
+void BM_Time_FromCivilDay0_CCTZ(benchmark::State& state) {
const cctz::time_zone tz = TestTimeZone();
int i = 0;
while (state.KeepRunning()) {
@@ -914,9 +912,9 @@ void BM_Time_FromDateTimeDay0_CCTZ(benchmark::State& state) {
}
}
}
-BENCHMARK(BM_Time_FromDateTimeDay0_CCTZ);
+BENCHMARK(BM_Time_FromCivilDay0_CCTZ);
-void BM_Time_FromDateTimeDay0_Libc(benchmark::State& state) {
+void BM_Time_FromCivilDay0_Libc(benchmark::State& state) {
// No timezone support, so just use localtime.
int i = 0;
while (state.KeepRunning()) {
@@ -940,7 +938,7 @@ void BM_Time_FromDateTimeDay0_Libc(benchmark::State& state) {
benchmark::DoNotOptimize(mktime(&tm));
}
}
-BENCHMARK(BM_Time_FromDateTimeDay0_Libc);
+BENCHMARK(BM_Time_FromCivilDay0_Libc);
const char* const kFormats[] = {
RFC1123_full, // 0