Getting a per thread CPU statistics

Solution 1:

For a quick answer use SysInternal's Process Explorer. Double click on a process to open the details dialogue. the threads tab gives a sortable list of all threads including context switch delta and CPU time.

Solution 2:

Perfmon (Performance Monitor) should give you the details you want.

The following assumes Windows 2000, XP or Server 2003. I haven't checked but I think the performance monitor is a bit different in Vista, Windows 7 & Server 2008.

To run the Performance Monitor, go to Start > Control Panel > Administrative Tools > Performance

To add a graph for each thread of an application, right-click on the graph and choose Properties. You might want to remove any of the defaults that it comes with to give you a cleaner graph.

Click the "Add..." button and make sure "Use Local Computer Counters" is checked (unless you want to monitor a different server, in which case, go ahead and choose that option).

Under "Performance Object" choose "Thread"

Select the counter "% Processor Time", and then select all of the threads you wish to monitor (control+click to select multiple). Click "Add" and then "Close".

Back in the properties, you can customise the graph however you wish, by assigning colours, patterns, etc. Click OK.

You might need to start the graphing, if you do, then clicking the red STOP sign so that it's not enabled will start the graph.

Solution 3:

Process Monitor (sysinternals)

I would think that ProcessMonitor by Sysinternals (recently purchased by Microsoft) would probably work.

Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. It combines the features of two legacy Sysinternals utilities, Filemon and Regmon, and adds an extensive list of enhancements including rich and non-destructive filtering, comprehensive event properties such session IDs and user names, reliable process information, full thread stacks with integrated symbol support for each operation, simultaneous logging to a file, and much more. Its uniquely powerful features will make Process Monitor a core utility in your system troubleshooting and malware hunting toolkit.

Here is the link:

http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx