Archived

This topic is now archived and is closed to further replies.

kingy

FPS counter - proper way to use QueryPerformanceCounter?

Recommended Posts

Is this a good way to track how many frames per second have occured, assuming that frame is being incremented at each buffer flip and frame and starttime are set reset every second? ///////////////////////////////////////////////////////////////// iTemp=QueryPerformanceCounter(&iGetTickCount); sec=iGetTickCount.LowPart-starttime.LowPart; iTemp=QueryPerformanceFrequency(&lTemp); iFrameRate=(frame*lTemp.LowPart)/sec;

Share this post


Link to post
Share on other sites
well, QPC return a thousandth of a millisecond. so to get the milliseconds you want to do QueryPerformanceCount*1000. or better yet query the time resolution, then call QueryPerformanceCounter*Resolution. then you need to convert that to a second by multiplying it by 1000.

HHSDrum@yahoo.com
Polarisoft Home Page

Share this post


Link to post
Share on other sites
Be careful. Even though the most common frequency of the performance counter is 1,193,182 Hz, this is not guaranteed. I have seen posts claiming it is 100''s of times faster on some systems. It''s safer to do the math out the long way.

Share this post


Link to post
Share on other sites
Be careful. Even though the most common frequency of the performance counter is 1,193,182 Hz, this is not guaranteed. I have seen posts claiming it is 100''s of times faster on some systems. It''s safer to do the math out the long way.

Share this post


Link to post
Share on other sites