https://github.com/expnkx/fast_io/blob/725695664091bc4e8fbb05df446aaad93642bbf5/include/fast_io_hosted/time.h#L406 This is my implementation for clock_gettime
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10 From: Corinna Vinschen<mailto:[email protected]> Sent: Wednesday, April 28, 2021 15:05 To: [email protected]<mailto:[email protected]> Subject: Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible. On Apr 26 20:00, Christian Franke wrote: > System calls and resolutions of C++11 clocks: > > Mingw-w64 MSVC16 Cygwin > system_clock::now() 1 2 2 > steady_clock::now() 1 3 3 > high_resolution_clock::now() 1 3 3 > > where > 1: GetSystemTimeAsFileTime: >15ms to 1ms (unpredictable) > 2: GetSystemTimePreciseAsFileTime: <1us > 3: QueryPerformanceCounter: <500ns Not quite. Newer Windows versions support better alternatives compared to QueryPerformanceCounter. Thus on newer systems Cygwin uses QueryUnbiasedInterruptTimePrecise for CLOCK_MONOTONIC{_RAW} QueryUnbiasedInterruptTime for CLOCK_MONOTONIC_COARSE QueryInterruptTimePrecise for CLOCK_BOOTTIME{_ALARM} and, of course GetSystemTimePreciseAsFileTime for CLOCK_REALTIME GetSystemTimeAsFileTime for CLOCK_REALTIME_COARSE Apart from style issues, I vote for using GetSystemTimePreciseAsFileTime for CLOCK_REALTIME and only fall back to GetSystemTimeAsFileTime for CLOCK_REALTIME_COARSE or if the OS doesn't support the precise call. Please do keep in mind that there are assumptions of a minimum precision of gettimeofday in the wild, which are not really in our hands. If we can avoid upstream code to #ifdef time computations for Mingw separately, rather than just using gettimeofday on all supported platforms, it's certainly a win-win, isn't it? Corinna _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
