Jump to content
  • Advertisement
Sign in to follow this  
fooman_69

FPS variation

This topic is 4750 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

hiya! I have just implemented a simple fps counter type function
void UpdateFPS()
{
	fps.numFrames++;
	float currentUpdate = timer.GetTime() / 1000;

	if((currentUpdate - fps.lastUpdate) > fps.fpsUpdateInterval)
	{
		fps.count = fps.numFrames / (currentUpdate - fps.lastUpdate);
		fps.lastUpdate = currentUpdate;
		fps.numFrames = 0;
	}
}
Easy enough. Question is, I get variations from 50-113 fps. Is there a good way to get a consistent rate?? Or is this normal?

Share this post


Link to post
Share on other sites
Advertisement
Looks perfectly reasonable to me (unless I missed something)

However... (hehe there *had* to be one coming)
There is a much simpler method all together which I perfer...
Screw framerate all together & use frame frequency instead:
frequency=1/frame time
Divide 1 second by the number of seconds passed since the last frame was rendered to get a reading of how many of those frames would fit in a second
Now you can have framerates that update every frame instead of every second or so.
It's only an estimate ofcourse & is based on the current time & not any actual counting of frames, but it's good enough for me ;]

Also I apply a slight "blur" between these readings:
Store the framerate in a seperate variable & compare to the frequency
if the frequency is lower then drop the framerate to it immediately, if it's higher then increase the framerate alittle bit

This helps to make slowdown more visible

It might seem "fake", but then counting frames across gaps like seconds isn't an entirely accurate way of reporting game speed either

You might of noticed that the fps display in many games (like quake 3) updates every frame rather than every second(time period)
That's coz it's actually frequency reading

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!