CPU runs to 100%

BlitzPlus Forums/BlitzPlus Programming/CPU runs to 100%

JPD(Posted 2003) [#1]
Hello,

when I run my programm, my CPU ist 100% charged to capacity. What can I do? Is this normal??

J.P.D


_Skully(Posted 2003) [#2]
what is your program doing to consume so much processor time?

Wow
Skully


Gregor(Posted 2005) [#3]
Same problem here. I've made a simple pong game and my cpu takes the full 100%.

Are those if...endif or while...wend loops so cpu-intensive?


CS_TBL(Posted 2005) [#4]
It's a known issue .., view an image with acdsee while a B+ app is running? Have fun .. you need to alt-tab back to your app again to help acdsee viewing that image :P

It's said however that putting:

DELAY 2

into your mainloop solves a bit..


Fabian.(Posted 2005) [#5]
Are you using WaitEvent(0) or WaitEvent() in your main loop? (WaitEvent(0) takes much more CPU time)


Gregor(Posted 2005) [#6]
Indeed, it consumes about 20% less. With delay set to 4 it saves about 25%. And a delay set to 10 consumes less than half (on my computer)


Gregor(Posted 2005) [#7]
@fabian: I do not use waitevent in my pong-program


Arem(Posted 2005) [#8]
Try doing delay(#ofmillisecs).

Alternatively if you want your app to always run at 30 frames per second, so it is the same speed on every computer, you can do:

timer=createtimer(30)

and then use

waittimer(timer)

to wait for 1/30th of a second to go by before you draw the next frame. This should keep your CPU usage down to normal levels.


Gregor(Posted 2005) [#9]
That's silly. The WaitEvent command is not listed in the command reference list in B+.


CS_TBL(Posted 2005) [#10]
ofcourse it is..

>GUI Category
>> Events
>>> WaitEvent

Using events rather than polling is a better way to go anyway..


Gregor(Posted 2005) [#11]
I thought in the category 2d a-z I could find it. There's a lot to learn I see.


CS_TBL(Posted 2005) [#12]
In B+ events/gadgets are related to 'GUI'
Polling and drawing/sound/files etc. are related to '2d'