Sign in to follow this  
colinisinhere

Finding Average FPS?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this