@@ -794,7 +794,11 @@ void BM_Time_ToDateTime_Libc(benchmark::State& state) {
794
794
while (state.KeepRunning ()) {
795
795
std::swap (t, t2);
796
796
t += 1 ;
797
+ #if defined(_WIN32) || defined(_WIN64)
798
+ benchmark::DoNotOptimize (localtime_s (&tm , &t));
799
+ #else
797
800
benchmark::DoNotOptimize (localtime_r (&t, &tm ));
801
+ #endif
798
802
}
799
803
}
800
804
BENCHMARK (BM_Time_ToDateTime_Libc);
@@ -815,7 +819,11 @@ void BM_Time_ToDateTimeUTC_Libc(benchmark::State& state) {
815
819
struct tm tm ;
816
820
while (state.KeepRunning ()) {
817
821
t += 1 ;
822
+ #if defined(_WIN32) || defined(_WIN64)
823
+ benchmark::DoNotOptimize (gmtime_s (&tm , &t));
824
+ #else
818
825
benchmark::DoNotOptimize (gmtime_r (&t, &tm ));
826
+ #endif
819
827
}
820
828
}
821
829
BENCHMARK (BM_Time_ToDateTimeUTC_Libc);
@@ -934,7 +942,7 @@ void BM_Format_FormatTime(benchmark::State& state) {
934
942
const cctz::time_zone tz = TestTimeZone ();
935
943
const std::chrono::system_clock::time_point tp =
936
944
cctz::convert (cctz::civil_second (1977 , 6 , 28 , 9 , 8 , 7 ), tz) +
937
- std::chrono::nanoseconds (1 );
945
+ std::chrono::microseconds (1 );
938
946
while (state.KeepRunning ()) {
939
947
benchmark::DoNotOptimize (cctz::format (fmt, tp, tz));
940
948
}
@@ -947,7 +955,7 @@ void BM_Format_ParseTime(benchmark::State& state) {
947
955
const cctz::time_zone tz = TestTimeZone ();
948
956
std::chrono::system_clock::time_point tp =
949
957
cctz::convert (cctz::civil_second (1977 , 6 , 28 , 9 , 8 , 7 ), tz) +
950
- std::chrono::nanoseconds (1 );
958
+ std::chrono::microseconds (1 );
951
959
const std::string when = cctz::format (fmt, tp, tz);
952
960
while (state.KeepRunning ()) {
953
961
benchmark::DoNotOptimize (cctz::parse (fmt, when, tz, &tp));
0 commit comments