[time-nuts] Win XP and NIST time

Orin Eman orin.eman at gmail.com
Wed Mar 27 13:16:35 EDT 2013


On Wed, Mar 27, 2013 at 9:46 AM, Dan Kemppainen <dan at irtelemetrics.com>wrote:

>
> As for timing things on windows, check out how to read the performance
> counters in windows. I believe these are QueryPerformanceCounter and
>  QueryPerformanceFrequency in kernel32. In most modern systems these should
> give a time stamp from the system start, at the native core clock frequency.
>


If you use those, you have to lock the thread you are timing to one
CPU/Core as the performance counters are per CPU/Core and can get out of
step.  Or you can force your thread onto one CPU for the
QueryPerformanceCounter call.  This seems to be a bad idea to me as it
would add an indeterminate time before querying the counter (indeterminate
as if you are running on a different CPU, the OS would have to switch to
the one you requested).

Search for SetThreadAffinityMask and/or SetProcessAffinityMask along with
QueryPerformanceCounter.

Then all bets are off if you have a CPU that runs at variable speed if you
want the result to be actual time.

Orin.


More information about the time-nuts mailing list