« Measuring context switches :: a small expedition. Part II | Main | Measuring context switches :: a small expedition. Part IV »

Measuring context switches :: a small expedition. Part III

Lets see some results:
(24 -> 480) 0.229874s

3356 : 18
3365 : 18
3376 : 18
3382 : 18
3388 : 18
3397 : 18
3403 : 18
3409 : 18
3412 : 18
3412 : 18
3415 : 18
3421 : 18
3429 : 18
3429 : 18
3432 : 18
3456 : 18
3479 : 18
3585 : 18
3647 : 18
3691 : 18
4471 : 18
4756 : 18
8265 : 18
The program took about 0.23s to run, in that time it received 23 context switches. That means a context switch happened every 0.1s i.e. 10Hz. Thats not suprisingly the documented preemption time slice for Mac OS X.

A context switch on CPU 18 took on average about 3.400 cycles. One may assume at these times, that the CPU is otherwise idle.

10 times 3.400 cycles is the approximate number of cycles lost per second: 34.000 cycles. Since my CPU is running at about 3.4GHz with Turboboost, that means - in relation to 3.400.000.000 cycles - context switching lost me about 0.001 % performance.

Thinking about this opens up some interesting questions, but lets gather another CPUs results to get some more data... Next time.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on December 1, 2011 11:06 PM.

The previous post in this blog was Measuring context switches :: a small expedition. Part II.

The next post in this blog is Measuring context switches :: a small expedition. Part IV.

Many more can be found on the main index page or by looking through the archives.