Skip to main content
GameDev.net gamedev.net
🔒 Locked

Profiling Threads

Started by peter-lavalle Jul 26, 2007 at 11:39 AM 3 replies 1k views
Original Post
peter-lavalle
peter-lavalle
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.
SiCrane
SiCrane
Which version of Visual Studio are you using? Not all versions have built-in profiling.
peter-lavalle
peter-lavalle
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
Palidine
Palidine
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
psykr
psykr
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.