@@ -895,7 +895,7 @@ py_get_system_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
895
895
FILETIME system_time ;
896
896
ULARGE_INTEGER large ;
897
897
898
- GetSystemTimeAsFileTime (& system_time );
898
+ GetSystemTimePreciseAsFileTime (& system_time );
899
899
large .u .LowPart = system_time .dwLowDateTime ;
900
900
large .u .HighPart = system_time .dwHighDateTime ;
901
901
/* 11,644,473,600,000,000,000: number of nanoseconds between
@@ -904,18 +904,17 @@ py_get_system_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
904
904
PyTime_t ns = large .QuadPart * 100 - 11644473600000000000 ;
905
905
* tp = ns ;
906
906
if (info ) {
907
- DWORD timeAdjustment , timeIncrement ;
908
- BOOL isTimeAdjustmentDisabled , ok ;
907
+ // GetSystemTimePreciseAsFileTime() is implemented using
908
+ // QueryPerformanceCounter() internally.
909
+ if (py_qpc_base .denom == 0 ) {
910
+ if (py_win_perf_counter_frequency (& py_qpc_base , raise_exc ) < 0 ) {
911
+ return -1 ;
912
+ }
913
+ }
909
914
910
- info -> implementation = "GetSystemTimeAsFileTime ()" ;
915
+ info -> implementation = "GetSystemTimePreciseAsFileTime ()" ;
911
916
info -> monotonic = 0 ;
912
- ok = GetSystemTimeAdjustment (& timeAdjustment , & timeIncrement ,
913
- & isTimeAdjustmentDisabled );
914
- if (!ok ) {
915
- PyErr_SetFromWindowsErr (0 );
916
- return -1 ;
917
- }
918
- info -> resolution = timeIncrement * 1e-7 ;
917
+ info -> resolution = _PyTimeFraction_Resolution (& py_qpc_base );
919
918
info -> adjustable = 1 ;
920
919
}
921
920
@@ -1057,22 +1056,23 @@ py_win_perf_counter_frequency(_PyTimeFraction *base, int raise_exc)
1057
1056
}
1058
1057
1059
1058
1059
+ static _PyTimeFraction py_qpc_base = {0 , 0 };
1060
+
1060
1061
// N.B. If raise_exc=0, this may be called without the GIL.
1061
1062
static int
1062
1063
py_get_win_perf_counter (PyTime_t * tp , _Py_clock_info_t * info , int raise_exc )
1063
1064
{
1064
1065
assert (info == NULL || raise_exc );
1065
1066
1066
- static _PyTimeFraction base = {0 , 0 };
1067
- if (base .denom == 0 ) {
1068
- if (py_win_perf_counter_frequency (& base , raise_exc ) < 0 ) {
1067
+ if (py_qpc_base .denom == 0 ) {
1068
+ if (py_win_perf_counter_frequency (& py_qpc_base , raise_exc ) < 0 ) {
1069
1069
return -1 ;
1070
1070
}
1071
1071
}
1072
1072
1073
1073
if (info ) {
1074
1074
info -> implementation = "QueryPerformanceCounter()" ;
1075
- info -> resolution = _PyTimeFraction_Resolution (& base );
1075
+ info -> resolution = _PyTimeFraction_Resolution (& py_qpc_base );
1076
1076
info -> monotonic = 1 ;
1077
1077
info -> adjustable = 0 ;
1078
1078
}
0 commit comments