Jump to content
  • Advertisement
Sign in to follow this  
colinisinhere

Finding Average FPS?

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heres my code: after ever second the number of frames in that second is added to allFPS and numFrames adds 1 to itself.

const float getAverageFPS() {
		return (float)((unsigned int)allFPS/(unsigned int)numFrames);
	}


but it doesnt run, it just quits.... whats wrong?

Share this post


Link to post
Share on other sites
Advertisement
Just a small tip: you're giving away some accuracy to rounding errors here. A more accurate function would be:


const float getAverageFPS()
{
return ((float)(allFPS) / (float)(numFrames));
}


If you're really crazy about accuracy, go with double instead of float. Not really all that important here, but it might become a problem in other places where you do integer to floating point conversions and need accurate results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!