在 2021-04-22 20:35, Christian Franke 写道:
This patch significantly increases the precision of gettimeofday() on Windows 8 or later. It is then similar to Cygwin or Linux.It also affects C++11 std::chrono:*_clock as _GLIBCXX_USE_GETTIMEOFDAY is defined but not _GLIBCXX_USE_CLOCK_*.A similar change (or a call to getntptimeofday()) would possibly also make sense for clock_gettime(CLOCK_REALTIME,...).Drawback: GetSystemTimePreciseAsFileTime() is slower than the legacy function. But it is still reasonably fast. Average time per call on an old machine with i7-2600K: GetSystemTimePreciseAsFileTime(): 23ns GetSystemTimeAsFileTime(): <3ns
I don't think the complexity is worth. If users want precision they should use a monotonic clock such as `QueryPerformanceCounter()`. I can't think of any real usage of `gettimeofday()` which needs accurate results.
-- Best regards, Liu Hao
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public