Reputation: 301
In C#.NET, is there a way to measure the actual CPU time of a thread/task. This time should NOT include the blocking/preemption time. I know that a StopWatch can be used to measure the total time for a task from start to finish, but this will also include the blocking time. Is there a way to exclude the blocking time?
Upvotes: 1
Views: 297
Reputation: 180788
System.Diagnostics.ProcessThread.TotalProcessorTime will give you the amount of CPU time that a given thread has consumed.
Upvotes: 4