> Most importantly, objc_msgSend can
block.
It can? Doing what (I'm curious)? I know
from my own (somewhat superficial) investigations that the first call is
slower because some kind of lookup takes place but is there something
else? MTCoreAudio uses objC calls (actually NSInvocation, if memory
serves) in its IOProc, FWIW, and the overhead of a method call, on Intel, after
the initial lookup, as measured by me in gdb, is about 25 instructions. Or
as Brian says, cache an IMP via -[NSObject methodForSelector:], which is then
just a call through a pointer and thus slightly faster than a C++ virtual
function call. Having said all of which, I coded my audio stuff in
C++.
One thing I did find is that malloc can sometimes be very
slow (when it hits the kernel, presumably) so don't do this (or alloc any
objects) in time-critical code. If you do, your audio _will_
glitch.
Regards,
Paul Sanders.
|