Janne Blomqvist wrote:
the attached patch implements the SYSTEM_CLOCK intrinsics on the MinGW
and Cygwin targets using the GetTickCount/GetTickCount64 functions.
These should be quite robust monotonic clocks and AFAICS are the best
we can do on Windows.
I think using QueryPerformanceCounter is the better approach. It is
supported since Windows 2000 and recommended as high-performance
counter:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644900%28v=vs.85%29.aspx
I really dislike GetTickCount, which overflows after 50 days - that's
not what you want to have. And GetTickCount64 only exists since
Vista/2008. By contrast, QueryPerformanceCounter should allow for finer
resolution and it is already available since Windows 2000.
- Also Cygwin uses QueryPerformanceCounter for clock_gettime, now as is,
before it subtracted some offset which caused it to start with 0 from
process startup time. (I belive QueryPerformanceCounter counts from
system startup.)
- MinGW-w64 also uses it for the monotonic clock_gettime - at least in
experimental/winpthreads.
- I think MinGW does't support it (yet?).
* * *
Regarding clock_gettime: I really think we should check check
_POSIX_MONOTONIC_CLOCK as well. Currently, only MONOTONIC_CLOCK is
checked, which is always available (on POSIX conform systems).
See GLIBCXX_ENABLE_LIBSTDCXX_TIME in libstdc++-v3/acinclude.m4 - and in
particular ac_has_clock_monotonic.
Tobias