Don't know if this affects Amiga/Linux, but it does in Windows...
If you're using tight loops in Windows without the WaitWindowEvent() command,
the CPU can get used quite heavily. Take the following example: When running,
and when I check the Windows Task Manager, it shows that the loop is using a
massive 90% of my CPU's power:
Code: Select all
Repeat : r=r+1 : Until r=99999999
always put in a Sleep_(1) command in the loop, to release the CPU load during
the loop. This next example shows this, and reduces the loop's CPU usage to a
much more desirable 0% when running, without having too much of an impact on
the loop's speed. But note: If you're coding an app for fast speed, then you
should perhaps not use this tip as it slows down the loop by 1 millisecond each
time the loop runs. Thus, it may not be good for games, but for desktop apps,
it should be used in all tight loops, and especially those which don't call the
WaitWindowEvent() command at all.
Code: Select all
Repeat : Sleep_(1) : r=r+1 : Until r=99999999
PB - Registered PureBasic Coder
Edited by - PB on 24 April 2002 04:42:02