Reducing CPU load
Blitz3D Forums/Blitz3D Programming/Reducing CPU load
| ||
Hello everyone, I want to write a desktop Blitz3D app but I dont want it to take up ALL the available CPU cycles. I have tried 1. using VWait(NumFrames) but that seems to not have any effect for a windowed app. 2. using an empty loop until a time has elapsed - it doesnt reduce CPU load - it just runs the empty loop really really fast instead. I am looking for a command like Sleep or Wait or something. Any thoughts as to what else I might try? yinch'03 |
| ||
You have to remember that Blitz3D is geared for games, not applications. Therefore it wants as much of your CPU to itself as it can possibly get so the code runs as fast as possible. If you want to write an Windows app, you'd be better off looking at BlitzPlus. |
| ||
What GFK said. But, that aside, I know one of the wait commands frees up the CPU... um, have you tried DELAY? |
| ||
Delay will help a lot in this instance. |
| ||
Yep, Delay will do the job perfectly. I checked this out recently for LightBulb using the System Monitor that comes with Windows. On my machine, a delay of 10ms in the main loop reduced the CPU load reading from 100% to ~55% with no noticable drop in performance. |
| ||
I find this kind of loop reduces CPU time to around 10% usage:timer=createtimer(30) Repeat WaitTimer timer Cls ; draw stuff etc .. Flip False ; < - Important to use FALSE here Until you have had enough |
| ||
Thanks everybody, that is really helpful. yinch'03 |