100% CPU

BlitzMax Forums/BlitzMax Programming/100% CPU

HrdNutz(Posted 2005) [#1]
Hello,

I am wondering if it is possible to make my game use less than 100% CPU in windowed mode? I know games run as fast as possible, but I wonder if anyone has any tricks that they use. Even if I just have an empty loop, it eats up 100%.

Thanks in advance


xlsior(Posted 2005) [#2]
delay <number>

Depending on how fast your game actually runs and how much CPU power your application can 'afford' to waste, use something like 'delay 10' or 'delay 100' in your main loop.


Robert Cummings(Posted 2005) [#3]
An empty loop shouldn't be 100% in max anyway. Are you using flip?


Mark Tiffany(Posted 2005) [#4]
Or WaitEvent()?


HrdNutz(Posted 2005) [#5]
A loop without flip or anything takes up 100% of my 3700+ AMD. A simple Graphics and a while loop which waits for escape, no flip no drawing nothing instide the loop.


ozak(Posted 2005) [#6]
Yup. Use events. Just like Blitz2D


Gabriel(Posted 2005) [#7]
Yup. Use events. Just like Blitz2D


You mean BlitzPlus? Cuz Blitz2d didn't have any events.


Robert Cummings(Posted 2005) [#8]
A loop without any flips or anything is *supposed* to take up 100% of your cpu time.

In a normal situation with flip, it should take no more than 10%.

Anything running on an empty infinite loop is demanding 100% of the time!

This is a non issue and nothing to worry about. Start actually MAKING a game - THEN compare.


ImaginaryHuman(Posted 2005) [#9]
Does the flip command automatically release and remaining frame time to the system? Would be a nice feature, to keep things synchronized but also share any spare time.


Robert Cummings(Posted 2005) [#10]
It releases a lot of time. Try it out and see. Thats my game though, your milage will differ. You can use waitEvent and set a timer to call a tick event too.


ozak(Posted 2005) [#11]
Whatever. I meant BlitzPlus since it's not Blitz3D and not BlitzMax :)


FlameDuck(Posted 2005) [#12]
Does the flip command automatically release and remaining frame time to the system?
It's driver dependant. Some drivers idle-wait for vsync, some busy-wait.


Dreamora(Posted 2005) [#13]
Driver settings dependant you mean ... :-)