Reducing CPU usage
Blitz3D Forums/Blitz3D Programming/Reducing CPU usage
| ||
First I better say that I didnt make this discovery, It was posted here elsewhere but I thought that it would very important or interesting to some people. Adding this routine reduced CPU usage by 5%-15% instead of full-on 100% even if your code is just delaying till the next frame inside a timing loop. New code used to keep my emulator at 60-FPS: timer#=MilliSecs() f=Int(timer#-oldtimer#) f=16-f If f>0 Then Delay f oldtimer#=MilliSecs() RESULTS: 1.lower CPU cooling fan speed and therefore less noise. 2.lower power consumption for notebooks. 3.lower CPU core temperatures. |
| ||
If you want to see a working example of this try my Emulator2001 here: adding an extra 1 millisecond delay further reduces CPU usage down to 75% thats not bad compared to 100% http://www.gstsoftware.co.nz/ |
| ||
I use something similar to this in my games. I set a max fps constant, and if a frame renders faster than one frame should take at that fps then I delay it to pad it out to the right time. |
| ||
even if your code is just delaying till the next frame inside a timing loop. even if you're only adding "Delay 1" to a timing loop, it will unlock most CPU time. |