Page 1 of 1

CPU Usage

Posted: Thu Jan 06, 2011 10:08 pm
by dnxviral
On average, of low level games, what is the CPU Usage?
And if I consider this too much, how would I lower it. I know most programs run very low on usage.

Thanks, dnx

Re: CPU Usage

Posted: Thu Jan 06, 2011 10:23 pm
by Ginto8
Once again, you're worrying too much about things. In a "minor" game, you will see low-to-mid range CPU usage when it is functioning normally. However, it will be easily visible when it isn't, because you will often see twice as much or more. How to fix an actual issue like that is just to debug your program and find where it goes into an uncontrolled infinite loop.

however, the implied intention of your question is to determine how to squeeze every last cycle out of your program. For this, I would hereby like to present my 2 favorite bits of programming advice: "Premature optimization is the root of all evil." (Donald Knuth) and "When in doubt, use brute force." (Ken Thompson). You are looking to make savings of millisecond amounts, and you aren't doing millions of iterations per second of whatever you're doing. Instead of worrying about trivial things like program size and program performance, which can all be easily fixed later (as long as the bad performance isn't due to a horrible design), you should spend more time designing your software so that you can maintain it without driving yourself insane, reuse code from it, and gain as much information as possible from the experience.

Design is one of the most important parts of software engineering, just as imagination is one of the most important parts of storytelling. Stories can have minor inconsistencies (especially the first time they're told) as long as they aren't critical to the meaning of the story.

Re: CPU Usage

Posted: Fri Jan 07, 2011 6:15 am
by N64vSNES
Ginto8 wrote:Once again, you're worrying too much about things. In a "minor" game, you will see low-to-mid range CPU usage when it is functioning normally. However, it will be easily visible when it isn't, because you will often see twice as much or more. How to fix an actual issue like that is just to debug your program and find where it goes into an uncontrolled infinite loop.

however, the implied intention of your question is to determine how to squeeze every last cycle out of your program. For this, I would hereby like to present my 2 favorite bits of programming advice: "Premature optimization is the root of all evil." (Donald Knuth) and "When in doubt, use brute force." (Ken Thompson). You are looking to make savings of millisecond amounts, and you aren't doing millions of iterations per second of whatever you're doing. Instead of worrying about trivial things like program size and program performance, which can all be easily fixed later (as long as the bad performance isn't due to a horrible design), you should spend more time designing your software so that you can maintain it without driving yourself insane, reuse code from it, and gain as much information as possible from the experience.

Design is one of the most important parts of software engineering, just as imagination is one of the most important parts of storytelling. Stories can have minor inconsistencies (especially the first time they're told) as long as they aren't critical to the meaning of the story.
+1

Re: CPU Usage

Posted: Fri Jan 07, 2011 3:13 pm
by dnxviral
Ginto8 wrote:Once again, you're worrying too much about things. In a "minor" game, you will see low-to-mid range CPU usage when it is functioning normally. However, it will be easily visible when it isn't, because you will often see twice as much or more. How to fix an actual issue like that is just to debug your program and find where it goes into an uncontrolled infinite loop.
I'm considerably worried about processing just because I'm not doing much with the game yet. Do you mean that cpu usage is noticeable at the beginnings of development? This doesn't seem logical...
But as for infinite loops. I only have a continues loop in a thread for game mechanics and such, thread is also closed on exit.
Ginto8 wrote:Design is one of the most important parts of software engineering, just as imagination is one of the most important parts of storytelling. Stories can have minor inconsistencies (especially the first time they're told) as long as they aren't critical to the meaning of the story.
The framework of the actual program is nice and neat :) I like the way I've organized the design but I'm just worried about the implementations, if their taking up too many resources.

Re: CPU Usage

Posted: Fri Jan 07, 2011 5:16 pm
by dandymcgee
dnxviral wrote:
Ginto8 wrote:Once again, you're worrying too much about things. In a "minor" game, you will see low-to-mid range CPU usage when it is functioning normally. However, it will be easily visible when it isn't, because you will often see twice as much or more. How to fix an actual issue like that is just to debug your program and find where it goes into an uncontrolled infinite loop.
I'm considerably worried about processing just because I'm not doing much with the game yet. Do you mean that cpu usage is noticeable at the beginnings of development? This doesn't seem logical...
But as for infinite loops. I only have a continues loop in a thread for game mechanics and such, thread is also closed on exit.
As soon as you limit the frame rate you'll go from 100% CPU usage to 2% easy. The continuous loop is most certainly the cause.

Re: CPU Usage

Posted: Fri Jan 07, 2011 8:05 pm
by dnxviral
dandymcgee wrote:
dnxviral wrote:
Ginto8 wrote:Once again, you're worrying too much about things. In a "minor" game, you will see low-to-mid range CPU usage when it is functioning normally. However, it will be easily visible when it isn't, because you will often see twice as much or more. How to fix an actual issue like that is just to debug your program and find where it goes into an uncontrolled infinite loop.
I'm considerably worried about processing just because I'm not doing much with the game yet. Do you mean that cpu usage is noticeable at the beginnings of development? This doesn't seem logical...
But as for infinite loops. I only have a continues loop in a thread for game mechanics and such, thread is also closed on exit.
As soon as you limit the frame rate you'll go from 100% CPU usage to 2% easy. The continuous loop is most certainly the cause.
Ahhhhh ok makes sense. Thanks a lot :)