Jump to content
  • Advertisement
Sign in to follow this  
peter-lavalle

Profiling Threads

This topic is 4153 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 am working with 2 different frameworks, and I would like to see why my solution is consuming all the CPU power available. I believe I can get this information easily by running a profiler which will watch the threads - I believe this is built into Visual Studio so ... how do I use Visual Studio's profiling mechanism? I don't mean profile guided optimisation.

Share this post


Link to post
Share on other sites
Advertisement
Which version of Visual Studio are you using? Not all versions have built-in profiling.

Share this post


Link to post
Share on other sites
I am using Visual Studio Professional 2005 (I got it through MSDN-AA) without any service packs. The service pack install crashes my computer and sometimes necessitates a reinstall of the IDE

Share this post


Link to post
Share on other sites
If you never sleep your threads they will consume 100% of the CPU power since they will be tight looping as fast as possible. For a fullscreen app, this is acceptable. If you want to be nice in windowed mode, throw in a sleep call when a given thread has nothing to process.

There's nothing wrong with 100% CPU usage. With Sleep(0) calls, you'll still own 100% of whatever the user isn't using for other tasks.

-me

Share this post


Link to post
Share on other sites
Be careful when saying that 100% CPU is acceptable. As a basic example, consider users on a notebook PC; if you use all the CPU, it will eat up the battery life. What happens when a background task starts up? Then your game will go to 50%, and if it needs 100% to run acceptable then it will become choppy at seemingly random intervals.

Sleep(0) is also not a good solution if you want to give up some processing time; I believe that there are some thread priority issues. IIRC there is a function to explicitly yield your timeslice on Win32, but I can't say for sure.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!