To main page | 3dengine.org

Frames per second


Frames per second (or fps) is a measure of performance used in games to determine how smooth will the game look for user. If the framerate is below 25 frames per second, the game need performance tuning and optimization.

Calculation

Typically it is actually calculated how many times the drawing cycle started until 1 second has passed, other methods (like calculating how many milliseconds the drawing of frame took) lack the need precision.

Also it should be noted that in order to measure framerate of more than 60 fps, one needs to disable vsync, which limits framerate to 60.

PyOpenGL

import time
last_time = time.time()
frames = 0

while True:

    ..... your opengl routine for 1 frame ....
    
    frames += 1
    if time.time() - last_time >= 1:
        current_fps = frames / (time.time() - last_time)
        print current_fps, 'fps'
        frames = 0
        last_time = time.time()