[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
PerformanceTimers
Performance timers are interfaced with two windows functions: BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency); BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
By dividing the value returned with QueryPerformanceCounter by the value returned with QueryPerformanceFrequency, you can measure seconds (or any fraction thereof). For example:
At this point, (end-start)/frequency = time in seconds between start and end.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
PerformanceTimers
Performance Timers
While not present on every single system, I have yet to find a computer that does not have performance timers. If you have ever run into problems with the windows timers being too slow, then performance timers may solve your problem. Windows timing messages, as well as most functions that retrieve time, usually have resolutions of 40-50 ms, which is unacceptable for many applications. Programs that use the video hardware can use vertical retrace synchronization, but even this is not always available.Performance timers are interfaced with two windows functions: BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency); BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
By dividing the value returned with QueryPerformanceCounter by the value returned with QueryPerformanceFrequency, you can measure seconds (or any fraction thereof). For example:
QueryPerformanceFrequency(frequency); QueryPerformanceCounter(start); // Start ... QueryPerformanceCounter(end); // End
At this point, (end-start)/frequency = time in seconds between start and end.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
