4

Is it possible to check how much cpu time context switching is taking on windows, or better yet, an .net process?

2
  • Do you mean how much time the actual context switches are taking? Or do you mean how much CPU usage wouldn't have happened if not for a context switch? These are two very different things because a significant fraction of the cost of a context switch comes after the context switch in the form of caches that don't hold useful data. Sep 8, 2015 at 18:17
  • How much time of the processor is crunching context switches in a given time. like kernel time, but only accounting context switching.
    – Dangling
    Sep 8, 2015 at 21:58

1 Answer 1

6

Performance Monitor can be used to see the % processor time and # of context switches. The context switch counts are available in either:

  • System\Context Switches/sec counter reports system wide context switches.
  • Thread(_Total)\Context Switches/sec counter reports the total number of context switches generated per second by all threads

Context switch overhead is low but if you see a much higher number at the same time as % processor time spikes then you can start troubleshooting what is occurring at that time. Other counters can help with narrowing down what the problem might be - for example Processor Queue Length.

Ref: TechNet Monitoring Context Switches

As well from another article on Context Switches:

You can determine whether context switching is excessive by comparing it with the value of Processor\% Privileged Time. If this counter is at 40 percent or more and the context-switching rate is high, then you can investigate the cause for high rates of context switches.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .