How to Calculate Frames Per Second
A frame rate is used to determine how well an application such as a 3D game is performing. A high frame rate means that many frames are being rendered per second, so the application is running smoothly. Calculating an application's frame rate is a straightforward process of measuring the time it takes for a frame to render, then converting the time to frames per second.
Instructions
-
-
1
Record the time that you start rendering a frame. Most languages have a function that returns the number of milliseconds that have passed since midnight. This value works perfectly for calculating frames per second.
-
2
Record the time that you start rendering the next frame.
-
-
3
Subtract the first time from the second. This gives the number of milliseconds that the first frame took to render.
-
4
Divide 1,000 by the number of milliseconds that the frame took to render. This converts from milliseconds per frame to frames per second.
-
1
Tips & Warnings
The calculation will fail if a frame renders in less than one millisecond. The last step will be a division by zero. Always check to make sure the difference is measurable.
If a frame is rendered while the time hits midnight, the calculation will result in a very tiny negative number. Use a special case to adjust the timer at midnight.