weird FPS


18-11-2008 21:58:13


i am working on a little game engine and am implementing a timing functionality which controls the game loop and calculates statistics such as frames per second, updates per second. I have been getting some weird values in the last few days and have finally decided to ask you guys if you know someting that I do not (which is pretty likely :D ).

I thought my FPS calculation was buggy since the values were always way off the FPS Values Ogre seems to calculate.

Avg FPS: 302,00005000125 <== My calculated value
Ogre Last Fps: 24,2483

After trying to find possible mistakes in my code and rewriting everything from scrath on and on, it always ended in the same phenomenon. So then I added Thread.Sleep( 500 ) to my main loop, assuming that I should get a framerate at around 2 FPS. And this is what I got:

Avg FPS: 1,99718174316474
Ogre Last Fps: 1,992032

So this shows me two things: 1. My calculation can't be too far off. And 2. Ogre's neither. So what the heck is going on in the first case? Assuming that my calculations are not wrong, I can only conclude that Ogre may have some framerate limitation activated or so, since my loop seems to be running at around 300 FPS and calling the RenderOneFrame() every time.

Anybody know if there could be such a limitation? How could I deactivate it?



I continued forcing the loop into framerates with Sleep. I got the following results:

Sleep( 50 ) ~20 FPS:
Avg FPS: 18,2121325949276
Ogre Last Fps: 18,28681

Sleep( 40 ) ~ 25 FPS:
Avg FPS: 22,253193960511
Ogre Last Fps: 21,97802

From here on (somewhere around 22 - 25 FPS), Ogre never gets any higher.

Sleep( 30 ) ~ 33 FPS:
Avg FPS: 28,3399739795089
Ogre Last Fps: 23,50637

Also note that since I am doing a lot of logging and other stuff except for "sleeping" so the ideal framerate cannot be achieved. Besides that, my FPS displayed here is smoothed (averaged) over 5 frames.


19-11-2008 23:07:15

I think I solved this (sort of). I closed Visual Studio and called the .exe directly. The log then show this:

2008-11-20 00:02:02,808 [3664] DEBUG Temporary General Logger (null) - Avg FPS: 250 Avg UPS: 250
2008-11-20 00:02:02,813 [3664] DEBUG Temporary General Logger (null) - Ogre Last Fps: 240,7592

Now that looks way better, I'd say :-) So I can assume that I will be doing lots of debugging outside of VS, right?

Any suggestions what might be the reason for this? I have Ogre within a Windows form (on a Panel), so probably it is somehow related to the way the VS Debugger handles Forms or so.


01-02-2009 02:05:29

Well, I am not sure what you are doing without seeing your code, but this is how I calculate the update time for objects (in microseconds). I just use ogre's fps, but I have provided some code to predict the framerate.

private Timer _UpdateTimer = new Timer();
private double _TimeSinceLastUpdate = 0; //in microseconds

private void Run()

while ( !Shutdown && !_RenderWindow.IsClosed )
if ( _Root.RenderOneFrame() )
//! Update timing information.
_TimeSinceLastUpdate = _UpdateTimer.Microseconds;

//! Print FPS...
double UpdateInSeconds = _TimeSinceLastUpdate / 1000000; //convert to seconds
double FPS = 1.0/UpdateInSeconds; //divide 1 second by the time taken to render 1 frame
System.Console.WriteLine( "FPS: " + FPS );

//! Update the game objects with the time passed since the last update
//UpdateGame( _TimeSinceLastUpdate );


If you lost focus of your form, then you may have gotten some weird results.

Edit: I just noticed the post date. Sorry about the bump.