Inaccurate FrameStarted frameEvent.TimeSinceLastFrame


14-02-2011 09:59:54

I've had some issues with stutters in my program (camera twitching occasionally), so started investigating the time between frames.

I have compared the times from frameEvent.TimeSinceLastFrame with values from my timings using the .NET Stopwatch class. timeSinceLastFrame produces some very low values ~1% of the time, typically 0 or 0.001 seconds, while my method shows lowest values of ~ 0.054s over the same time periods (I track 100 frames worth and put out the lowest and highest values). The longest and average values are similar to my method. The timeSinceLastFrame value also appears to have limited resolution only showing 2sf.

Is this a bug?

I'm using Win7 64bit and Mogre

For anyone else with this issue, I've changed to using Stopwatch and averaging the last 5 frames when predicting the length of the next frame (which you typically do for working out how far to move the camera).... well, I actually take the minimum of this average and the time to render the last frame for the camera so that I know it won't jump dramatically; the worst that will happen is it will stall. YMMV.


19-02-2011 18:28:43

I also noticed glitchy behavior when using frameEvent.TimeSinceLastFrame to do mhydrax updates, so i made a worker thread and a fixed interval for the updates