CPU Usage

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
dnxviral
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 51
Joined: Tue Dec 14, 2010 6:49 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: Everything... and C#
Location: dnXstudios
Contact:

CPU Usage

Post 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
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: CPU Usage

Post 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.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: CPU Usage

Post 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
dnxviral
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 51
Joined: Tue Dec 14, 2010 6:49 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: Everything... and C#
Location: dnXstudios
Contact:

Re: CPU Usage

Post 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.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: CPU Usage

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
dnxviral
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 51
Joined: Tue Dec 14, 2010 6:49 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: Everything... and C#
Location: dnXstudios
Contact:

Re: CPU Usage

Post 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 :)
Post Reply