High-Performance Counter Support

There are two built-in high-performance counter routines, QueryPerformanceCounter and QueryPerformanceFrequency. QueryPerformanceCounter returns a 64-bit number representing timer counts and QueryPerformanceFrequency returns the number of high-performance ticks per second. It is used to convert counts to a time value.

In many cases, platforms do not implement 64-bit high-resolution counters in hardware. A workaround is to implement the counter using 32-bit hardware counters and implement the rollover to 64-bits through an interrupt.

Another is to use the thread scheduling timer to update a 64-bit tick count. Like PerfCountSinceTick, this works well if the underlying hardware timer has a large number of ticks per millisecond. Otherwise, OEMQueryPerformanceCounter does not offer much of an advantage over GetTickCount.

If the thread timer tick will meet your needs, you can use the boilerplate implementations of QueryPerformanceCounter and QueryPerformanceFrequency provided with the sample platforms. The sample routines are implemented in terms of PerfCountSinceTick and PerfCountFreq, which are also used in interrupt latency timing.

See Also

Supporting High-Resolution Timers | Implementing the OEMInit Function | PerfCountSinceTick and PerfCountFreq

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.