Let's find a way to limit the CPU usage in games.
Posted: Thu Mar 10, 2005 5:43 pm
My example. (don't run directly from the zip file)
In my example I used this code to limit the CPU usage without causing any lagg:
Without this code the CPU usage was constant 100%, with it was ca.0-8%.
But how can I convert this to frame rate, if I want it to run at 85 or 60 fps?
I searched the forum for other posts about this.
And I noticed in one of Psychophanta's posts that he said this:
Feel free to post your own code snippets to limit the CPU usage.
Edit: I noticed I could change 11 to 15 without causing any lagg, but it lagged a little on 16...
In my example I used this code to limit the CPU usage without causing any lagg:
Code: Select all
timeDelay = ElapsedMilliseconds() - masterTimer
masterTimer = ElapsedMilliseconds()
If timeDelay < 11
Delay(11 - timeDelay)
EndIfBut how can I convert this to frame rate, if I want it to run at 85 or 60 fps?
I searched the forum for other posts about this.
And I noticed in one of Psychophanta's posts that he said this:
And i'm 100% agree with him.I've noticed that ALL the time used when the FlipBuffers() function WAITS FOR actually swap the screen buffers seems to be wasting CPU resources, what is innecessary. So, if that is true, it is sure that the FlipBuffers() function need to be modified.
Feel free to post your own code snippets to limit the CPU usage.
Edit: I noticed I could change 11 to 15 without causing any lagg, but it lagged a little on 16...