bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: measuring elapsed time on mingw


From: Eric Blake
Subject: Re: measuring elapsed time on mingw
Date: Mon, 05 Apr 2010 08:25:03 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Thunderbird/3.0.4

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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]