Skip to main content
gamedev.net
🔒 Locked

QueryPerformanceCounter()

Started by jho 3 replies 300+ views
Original Post
jho
jho
Hi, I got the number of ticks from QueryPerformanceCounter(), how do I convert it to Milli-Second? Do I use QueryPerformanceFrequency() to get the clock Frequency, and go ticks / frequency / 1000.0?
Sly
Sly
Is QueryPerformanceCounter() guaranteed to return microseconds? The documentation does not say so, and if so, why would there be a QueryPerformanceFrequency() function? Do not rely on the frequency being in microseconds. It may change between different hardware.

QueryPerformanceFrequency() returns the number of counts per second. So in terms of a second, divide the count by the frequency. Then to get milliseconds, multiply by 1000.

((float)count / (float)frequency) * 1000



Steve 'Sly' Williams
Tools Developer
Krome Studios
jho
jho
He''s wrong, QPC returns ticks, you figure out mircoseconds by using Freq. * 1000? are you sure? Then it''s saying I used 150,000 ms to do a cycle. I didn''t feel THAT LONG. more like 150 ms.


Knarkles
Knarkles
It''s count / freq / 1000.0.

-Jussi

(quote space for sale (for free))

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.