How to measure time spent in context switch