On 04/04/2010 04:41 AM, Bruno Haible wrote: > Hi, > > Just a side note about how to measure elapsed time on mingw. > (I needed this in order to evaluate how to implement nanosleep on mingw.) > > Summary: > - GetSystemTimeAsFileTime, _ftime, gettimeofday (from newer mingw runtimes) > all have about 15.6 ms resolution.
Actually, they have a resolution that is variable length. It defaults to 15.6 ms, but you can get it down to 1 ms with other tricks, although it has performance ramifications across all processes running on the machine (whether or not those other processes needed the extra resolution). > - QueryPerformanceCounter [1] has a resolution of 0.5 ms or higher. Yes, this is probably the best call to use for raw resolution, but if you use it, then you run into the issues of file timestamp mismatch (cygwin currently has a known issue where, because it uses QueryPerformanceCounter instead of GetSystemTimeAsFileTime for implementing utimensat(UTIME_NOW), a file can not only appear newer than what a corresponding file system operation would be, but also time can appear to travel backwards when following a utimensat(UTIME_NOW) operation by a normal file system operation). As a result, all of the gnulib tests that inspect sub-second resolution of file timestamps have to insert the equivalent of usleep(20000) to ensure that events are far enough apart to be observable without time apparently traveling in reverse. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature