Corinna Vinschen wrote:
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}
Thanks for chiming in. I obviously forgot to look at Cygwin's current
clock.cc :-)
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.
+1 from me.
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?
I agree.
The reason for this patch: I searched for a timer with ~1ms resolution
for ioctl() duration measurement in debug output of smartmontools. It
should work without any #ifdef with Cygwin, MinGW-w64, MSVC16, Linux,
*BSD, ...
All three C++11 std::chrono clocks could be used, with MinGW-w64 as the
only exception. MinGW-w64 uses gettimeofday() for these clocks.
--
Best regards,
Christian Franke
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public