Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » rest(1) 65 fps!?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
rest(1) 65 fps!?
Albin Engström
Member #8,110
December 2006
avatar

ok.. when i use rest(1) my game fps drops to 65(64)! in both double and triple buffering. i searched the forums and found an abandoned thread about this, so lets get on with this unfinished business!

heres the thread: http://allegro.cc/forums/thread/585737

i have no memory of this problem at home (i'm in school now).

i don't know what to say so... i'll let you do the talking.

:-/

miran
Member #2,407
June 2002

What happens if you do rest(0)?

--
sig used to be here

HoHo
Member #4,534
April 2004
avatar

Is 65FPS too little?
What is the CPU usage?

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Johan Peitz
Member #9
April 2000
avatar

What is the FPS otherwise?

--
johan peitz :: things I made

Albin Engström
Member #8,110
December 2006
avatar

rest(0) acts the same as no rest(x) at all.

"Is 65 FPS too little?"

yeah, without rest(1) the fps is almost 600 in double buffering.
with rest(1) 64..

i don't have time to test triple buffering, i'll post a result as soon as i get home.

HoHo
Member #4,534
April 2004
avatar

Quote:

yeah, without rest(1) the fps is almost 600 in double buffering.

I didn't ask how fast it is without the rest, I asked if it is too slow to be playable. There is a difference.

I wouldn't worry about speed unless your program runs unplayably slowly with the final graphics and effects. Trying to optimize stuff that runs at several hundred FPS is just not a waste of time.

My guess is that rest(1) uses the OS thread schedular granuality, on Windows that should be around 15-16ms. On Linux it can be from 1-10ms. That means every time you call rest with >0 parameter you will rest at minimum the it takes the OS to do a context switch.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Archon
Member #4,195
January 2004
avatar

Quote:

yeah, without rest(1) the fps is almost 600 in double buffering.
with rest(1) 64..

Perhaps your FPS will stay at around 65 even if you add another million things to render per loop.

miran
Member #2,407
June 2002

Quote:

rest(0) acts the same as no rest(x) at all

I thought if you limited your logic and drawing to a certain framerate, rest(0) would make sure your program didn't use 100% CPU time. At least I think it was like that at one point...

--
sig used to be here

GullRaDriel
Member #3,861
September 2003
avatar

No, rest(0) give processor back to other process if they need it. If not, you will keep eating the CPU.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Onewing
Member #6,152
August 2005
avatar

I've tinkered around with this lately.

First off, rest(1) shouldn't have that huge of a difference on your fps. I was running my game at 90fps (average), added rest(1), and it went to 89fps (average). Thus, you probably have rest(1) at a weird spot. I only do rest(1) when I'm ahead, like so (writing code from memory):

1// system_time is incremented by the hardware interrupt
2void play_game()
3{
4 while(!quit)
5 {
6 while(system_time > 0)
7 {
8 update_logic();
9 system_time--;
10 }
11 
12 draw_game();
13 if(system_time == 0)
14 rest(1);
15 }
16}

If perhaps you put the rest(1) in the function used as the hardware interrupt, yeah, fps is going to suffer significantly.

My program seems to be pretty intensive, rest(0) seems to give nothing back to the PC, rest(1) a smidget, and rest(10) gives a decent amount, although makes the game lag somewhat.

[edit]
Also, 65fps is not a bad number! 600 is ridiculous, your monitor can't even draw that much. Throw in a vsync and you'll see a more realistic number.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

bamccaig
Member #7,536
July 2006
avatar

'An average 17" monitor can reach 85 Hz, meaning that any performance reached by the game over 85 fps is discarded.' - Source

I'm no video expert, but I've always thought that 60 fps was great. According to that same article, Rockstar's GTA games are limited to 25-30 fps. How fast can the average human process an image anyway? 600 fps is insane! There's no point consuming cycles with your game if it doesn't need them.

HoHo
Member #4,534
April 2004
avatar

Quote:

How fast can the average human process an image anyway?

Highly depending on what kind of changes there are between sequental images. In cinema you see 11FPS movie and think it is nice and fluid. At home you or at least some people can separate individual frames in FPS running at >50FPS

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Onewing
Member #6,152
August 2005
avatar

Quote:

How fast can the average human process an image anyway?

A ninja can see 7000+.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

gnolam
Member #2,030
March 2002
avatar

HoHo said:

In cinema you see 11FPS movie and think it is nice and fluid.

I doubt you would, actually. Unless you added so much blur you'd think the projector operator was legally blind.

bamccaig said:

How fast can the average human process an image anyway?

A whole lot.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Albin Engström
Member #8,110
December 2006
avatar

ok.. sorry for the delay.. anyway:

double buffering | windowed | rest(0) | using vsync = 75 fps (correct)
double buffering | windowed | rest(0) | without vsync = 125 fps (unsure)

double buffering | fullscreen | rest(0) | using vsync = 75 fps (correct)
double buffering | fullscreen | rest(0) | without vsync = 155 fps (unsure)

double buffering | windowed | rest(1) | using vsync = 75 fps (correct)
double buffering | windowed | rest(1) | without vsync = 112 fps (unsure)

double buffering | fullscreen | rest(1) | using vsync = 75 fps (correct)
double buffering | fullscreen | rest(1) | without vsync = 135 fps (unsure)

triple buffering | rest(0) = 64-70 fps (??)
triple buffering | rest(1) = 75 fps (correct)

hmm, i don't think there's anything wrong here.. but then again it wasn't on this computer i discovered it.

the only thing i can think of now is: why does my computer get 1/4 fps in un-v-sync:ed double buffering of the computer in school? as far as i can tell, my computer is far superior..

i'm going to school tomorrow morning and take some tests there.. i remember the monitors refresh rate where 85, but i could get past 64 in some cases.

HardTranceFan
Member #7,317
June 2006
avatar

Albin, I have the same result as you for my game. If I don't use rest(x), it's around 350fps. If I put in a rest(1), it drops to 64fps. The game runs at 64fps no matter how much I push around the screen, so I'm not that bothered by it.

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

OICW
Member #4,069
November 2003
avatar

Hey, what's the matter with those FPS, unless it drops bellow 30, there's no need to worry. Movie is ussually shot at 24 FPS. Even if you have Quake 3 running at 15 FPS, you're not likely to see the actual frames. Besides 600 is evil, it eats 100% of CPU and therefore consume my battery on laptop.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

HoHo
Member #4,534
April 2004
avatar

Quote:

I doubt you would, actually. Unless you added so much blur you'd think the projector operator was legally blind.

I wonder where I heard about 11FPS, it should be around 18FPS actually. Sorry about the confusion.

Quote:

i'm going to school tomorrow morning and take some tests there..

Please measure the CPU usage also. If it is less than 50% you can stop further measurements and start writing the game!

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

GullRaDriel
Member #3,861
September 2003
avatar

People always want to have the quickest thing even when it is not needed.

Example:
For those who have a car, we admit it can easily reach 180 km/h. Do you even drive a whole travel at this speed ? No. That the same with your FPS. Even if it can reach the light speed, it is not needed.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

HardTranceFan
Member #7,317
June 2006
avatar

Quote:

That the same with your FPS. Even if it can reach the light speed...

Light speed fps? Now, that's my kinda computer. Imagine the amount of processing, computations and graphics you could push through that baby. Windows might just work at a reasonable speed on it.

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

GullRaDriel
Member #3,861
September 2003
avatar

HardTranceFan: ...

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Albin Engström
Member #8,110
December 2006
avatar

HardTranceFan said:

Albin, I have the same result as you for my game. If I don't use rest(x), it's around 350fps. If I put in a rest(1), it drops to 64fps. The game runs at 64fps no matter how much I push around the screen, so I'm not that bothered by it.

but it's not right? :S that enough is reason.

OICW said:

Hey, what's the matter with those FPS, unless it drops bellow 30, there's no need to worry. Movie is ussually shot at 24 FPS. Even if you have Quake 3 running at 15 FPS, you're not likely to see the actual frames. Besides 600 is evil, it eats 100% of CPU and therefore consume my battery on laptop.

15 fps.... that's overkill.. - -, it's not about 'seeing' the frames, it's about the feeling of smoothness.

HoHo said:

Please measure the CPU usage also. If it is less than 50% you can stop further measurements and start writing the game!

haha, that's what i want to do too.. but every time i start to "make a game" it ends because i know of a better way to do it - -. it just isn't fun to write code when the rest of the code sucks.. i have a scrapyard with about 600 files and 127 folders, and that's after i've cleaned it up..

GullRaDriel said:

People always want to have the quickest thing even when it is not needed.

that's NOT my case.. and the difference between X fps and X+ fps is visible! ok, "can't" see the frames, but thats the point, isn't it? the higher fps the smoother the movements, that's not a theory, it's a fact! i absolutely don't want a fps higher than what the monitor can display.

and 64 sucks!! if i have a monitor able to do 120(mine does 75) why would i want 64?? and for the second time: it IS visible. i don't understand why people can't see it..

HoHo
Member #4,534
April 2004
avatar

Quote:

but it's not right?

Why it isn't? You can't make meaningful decisions only based on FPS without looking at what the CPU does. In your and OICW's case it is probably idling most of the time and that is a good thing.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

HardTranceFan
Member #7,317
June 2006
avatar

nm

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

Kris Asick
Member #1,424
July 2001

Time to clear up some things:

If you put rest(1) in your game loop, it will burn 1 ms of processor time per frame, giving it back to the CPU. Thus the absolute maximum framerate possible would be 1000 fps, assuming your loop did practically nothing besides rest(1). If you're getting a huge framerate drop by adding rest(1), then you're probably adding it in the wrong spot and it's being called more than once per frame. To know for certain if it's working properly you need to make an empty loop that calls rest(1) a certain number of times, then compare that with an Allegro timer to see if the two are running the same speed. If not, I'm willing to bet that Allegro programs aren't the only ones having timing problems on your system.

Also consider that framerate drops exponentially for the amount of processing you're doing. For instance, if your game logic uses 5 ms of processor time, you would have a framerate of 200 FPS. If it uses 10 ms, 100 FPS. 20 ms, 50 FPS. 40 ms, 25 FPS. As you'll see, it doesn't take much extra to kill the framerate.

If you're not going to use rest(1) you must at least use rest(0), or else your game will not give any CPU time back to the system and background processes may stop working properly. Using rest(1) over rest(0) isn't necessary, but increases I/O compatability in Allegro 4.1.0 or higher under older Windows OSes. (Which is why I use it.)

Be careful where you put the rest() commands. Do not put them immediately before a vsync() or triple buffering command, do not put them inside an acquire/release pair, do not put them in your timer routines and be certain they're only being called once per frame. (Leave rest() commands out of loops that may repeat more than once per frame.)

If you're still having doubts, set up your rest() commands to be called less often than the framerate. (For instance, call rest(1) every four frames or so.) This might still work as intended, but I've never tried it (yet) so I can't guarantee it will.

Lastly, about framerates: The Human brain can distinguish individual frames up to around 24 FPS. After that, the brain no longer sees each frame, but motion. That does not mean the brain can't figure out higher framerates, it just means that the brain stops being able to perceive each individual frame. The point at which framerates become indistinguishable varies with each person. For me, it's around the 100 FPS mark. Movies run at around 24 FPS. Thus if you're making a game using a real-time game engine, don't worry about the framerate being only 60-something: Not too many people will be able to tell and even fewer will care.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

 1   2 


Go to: