21 #include "benchmark/benchmark.h" 41 void BM_Difference_Days(benchmark::State& state) {
44 while (state.KeepRunning()) {
46 benchmark::DoNotOptimize(n);
49 BENCHMARK(BM_Difference_Days);
51 void BM_Step_Days(benchmark::State& state) {
54 while (state.KeepRunning()) {
55 benchmark::DoNotOptimize(++c);
58 BENCHMARK(BM_Step_Days);
60 void BM_Format(benchmark::State& state) {
62 while (state.KeepRunning()) {
64 benchmark::DoNotOptimize(s);
70 void BM_CivilTimeAbslHash(benchmark::State& state) {
71 const int kSize = 100000;
72 std::vector<T> civil_times(kSize);
73 std::iota(civil_times.begin(), civil_times.end(), T(2018));
76 while (state.KeepRunningBatch(kSize)) {
77 for (
const T civil_time : civil_times) {
78 benchmark::DoNotOptimize(absl_hasher(civil_time));
82 void BM_CivilYearAbslHash(benchmark::State& state) {
83 BM_CivilTimeAbslHash<absl::CivilYear>(state);
85 void BM_CivilMonthAbslHash(benchmark::State& state) {
86 BM_CivilTimeAbslHash<absl::CivilMonth>(state);
88 void BM_CivilDayAbslHash(benchmark::State& state) {
89 BM_CivilTimeAbslHash<absl::CivilDay>(state);
91 void BM_CivilHourAbslHash(benchmark::State& state) {
92 BM_CivilTimeAbslHash<absl::CivilHour>(state);
94 void BM_CivilMinuteAbslHash(benchmark::State& state) {
95 BM_CivilTimeAbslHash<absl::CivilMinute>(state);
97 void BM_CivilSecondAbslHash(benchmark::State& state) {
98 BM_CivilTimeAbslHash<absl::CivilSecond>(state);
100 BENCHMARK(BM_CivilYearAbslHash);
101 BENCHMARK(BM_CivilMonthAbslHash);
102 BENCHMARK(BM_CivilDayAbslHash);
103 BENCHMARK(BM_CivilHourAbslHash);
104 BENCHMARK(BM_CivilMinuteAbslHash);
105 BENCHMARK(BM_CivilSecondAbslHash);
time_internal::cctz::diff_t civil_diff_t
std::string FormatCivilTime(CivilSecond c)