I would like to know the best way to profile app code on OS X. I have a nano-second resolution timer and it seems after some baseline testing that I am hitting a kernel syscall context switch of about 45 micro (macbook 2ghz core2 duo model).
I’ve noticed that if I let my app cycle every now and then I can get a scheduling context switch of about 25,000-50,000 micro. I am testing some algorithms, and I want to limit the effects of this.
What I really want is to be able to set the processor affinity of a task and also to set the main thread priority to realtime, which is not a bad thing because one day this Macbook may be used as a low-latency controller for something. Any ideas on how to do this on snow leopard / XCode?
You can use Shark in Xcode. There’s also DTrace.