# SDL: Jumping fps

## Recommended Posts

Hello. Wasn't really sure where to put this, but I think my problem has more to do with SDL than programming in general. When I run my application on my slow computer, the frame rate keeps jumping between 71.4 fps and 83.3 fps. Always those two frame rates, and never the same frame rate two frames in a row. When I run the same application on a faster computer, the frame rate jumps between 250.0 fps and 500.0 fps. Some code:
void Timer::resetTimer()
{
startTime = SDL_GetTicks();
}

Uint32 Timer::getTime()
{
return(SDL_GetTicks() - startTime);
}

Each frame I call the functions getTime() and resetTimer() and use the time from getTime() to calculate the frame rate. I know it's normal for the frame rate to change from frame to frame, but when it changes like this I get the feeling something's wrong. Do you have any idea what could cause this? Thanks in advance.

##### Share on other sites
How are you calculating your fps? My guess is that it's in the floating point arithmetic. I.e 1000.0f/ticksElapsed if this is how you calculate your fps then the result fps will jump noticably when there's a slight change in ticksElapsed.

Example: ticksElapsed = 10 ==> 100 fps
ticksElapsed = 20 ==> 50 fps

As for more accurate calculation, you can look for higher precision timer.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627643
• Total Posts
2978363

• 10
• 12
• 22
• 13
• 33