Jump to content
  • Advertisement
Sign in to follow this  
fathom88

Silly CPU Utilization Question

This topic is 4764 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was trying to bring down the CPU utilization. I noticed something that I thought was strange. In a loop, I had to do some simple calculations before attempting to draw a point. I later realized that I could create a look-up table once in advance instead of doing the math in real time. I created a function to access the lookup table and set a container variable. I ran the app again and the utilization actually went up by 10%. Should the over-head of calling a function affect CPU usage this much?

Share this post


Link to post
Share on other sites
Advertisement
By speeding up the calculation, you are allowing the CPU to do more work, so the utilization goes up. It wasn't just the overhead of a function call, but also eliminating whatever was being done in that function.

Share this post


Link to post
Share on other sites
How big is your LUT? A cache miss can be more expensive than your simple calculations.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ignore the value, it means next to nothing, you can make it say whatever you want depending on how often you call Sleep, what else is running on your machine etc. Doing a simple for loop adding numbers together will use 100% CPU if you dont call Sleep and a full blown 3d game running at 60fps could show 50% if you call sleep. Time your code by all means but dont use the CPU usage percentage as any sort of indictation how well/fast your code is running.

Share this post


Link to post
Share on other sites
Thanks for all the replies. Timing the calls seems like a better idea. I wanted to optimize my drawing before coding my A.I..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!