Reduce loops used to calculate FPS

Issue #3 new
David Hayes created an issue

Currently you store an array of 50 frame times in this.amos.fps. In the renderer, every 10 frames, you loop over all 50 of these frame times to calculate a total time taken. However, if you precalculate the total time for all frames, then when you start a new frame, you can subtract the value in the array (that you are about to overwrite) from the total time, and then add the new previous frame time to the total time, as well as store that into the array.

This means every 10 frames, you only need to do the simple 1000 / ( total time / fps length ) calculation, not loop over all the frames.

Comments (1)

  1. Log in to comment