Please, consider implementation of the POSIX interface to high-resolutin timers:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
It will facilitate simple manual profiling and be useful in other situations that require precise measurement of time.
Diff:
Diff:
Thanks. I've attached patches, to add a tentative implementation, and one-shot autotest checks, for
CLOCK_REALTIMEandCLOCK_MONOTONICsupport; I've also provided source for a continuous, non-terminating test program, to exercise these clocks until interrupted by a console break.Do please note that this proposed
CLOCK_REALTIMEimplementation will achieve no better precision than the existinggettimeofday()API; expectations of sub-millisecond resolution of the time-of-day clock, on Windows, is likely a forlorn hope. Similarly, the proposedCLOCK_MONOTONICimplementation will achieve no better than the resolution of the system performance counter API.Just one point: when requesting POSIX feature enhancements, please refer directly to the official POSIX.1 specification, rather than to some third party reproduction. I've replaced your original third party reference accordingly.
Last edit: Keith Marshall 2017-08-13
Diff:
Thank you, Keith. I will soon try your patches. I also sent notice about this requiest to the mailing list via Gmane, but has not come through yet.
Last edit: Anton 2017-08-13
It arrived in my inbox. Gmane seems to be in a state of flux, at present; for a while, it wasn't working at all, and I don't think it has yet recovered its former reliability.
I'm inclined to support this request, (and not just because I already have a tentative implementation "ready to go"). We have provided the POSIX.1
gettimeofday()API, since Danny Smith added it in 2006. As of POSIX.1-2008, thisgettimeofday()API has been declared "obsolescent", (and thus likely to be dropped from the next formal release of POSIX.1); its recommended replacement is theclock_gettime()API, operating on theCLOCK_REALTIMEtiming entity, so it would seem sensible for us to support this.I committed [ecc51c], for inclusion in the upcoming
mingwrt-5.1release.Related
Commit: [ecc51c]