Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: What is the best way to calculate FPS?

Hybrid View

  1. #1
    Guest

    What is the best way to calculate FPS?

    Hello!

    I was wondering if there is a better way to calculate the fps. At the moment, I calculate over ten frames and divide this time to give fps like so:

    eventloop()
    if (tenframes == 0) ticks = TickCount();
    tenframes ++;

    //draw GL scene

    if (tenframes == 10)
    {
    tenframes = 0;
    ticks = TickCount() - ticks;
    fps = float(float(600.0) / float(ticks));
    }

    The only problem is that it changes every 10 frames to (sometimes) a completely different value! I was wondering how others calculate fps to see if there is something better...

    thanks!
    - patrick.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    547

    Re: What is the best way to calculate FPS?

    err yeah, for each frame calculate the time it has taken to draw. the fps then equals 1/(time for frame). Do it each frame not every 10, that seems a bit daft to me.

  3. #3
    Intern Contributor
    Join Date
    Aug 2000
    Posts
    93

    Re: What is the best way to calculate FPS?

    One simple method is to use tick counts to judge how long each frame takes. Divide this into 1000 to get FPS.

    Then use a trick like the following to average out the framerate:

    a = 1000/TickCount
    b = 50
    fps = (fps*(b-1)+a)/b)

    fps will will hold a nice accurate sort-of average reading of recent framerates.

    The higer you choose b the further back it reading extends. Note sadly early framerates will be innacurate until about 2bFrames have rendered. No problem if b ain't huge.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •