4 ms·
I have never used IMP caching, and don't think the average developer uses this (aside from indirect use of Apple's frameworks). Otherwise: > A normal Objective
by manmal 4y ago
I have never used IMP caching, and don't think the average developer uses this (aside from indirect use of Apple's frameworks). Otherwise:
> A normal Objective-C message send is a bit slower, as we'd expect. Still, the speed of objc_msgSend continues to astound me. Considering that it performs a full hash table lookup followed by an indirect jump to the result, the fact that it runs in 2.6 nanoseconds is amazing. That's about 9 CPU cycles. In the 10.5 days it was a dozen or more, so we've seen a nice improvement. To turn this number upside down, if you did nothing but Objective-C message sends, you could do about 400 million of them per second on this computer.
So it's 9 cycles vs what, one?
- lapcat 4y ago> So it's 9 cycles vs what, one? I'm not sure what you're asking? What are you trying to compare?
- manmal 4y agoI’m comparing a message send with a statically linked function call (or inlining, as mentioned by sibling comment).
- lapcat 4y agoThis has the feel of premature optimization. These are the fastest operations. Their running time starts to get overwhelmed by the slower operations as you go down the list of things tested. Making the fastest operations a few times faster doesn't necessarily have any noticeable effect on your program.
- manmal 4y agoYou made me think, thanks for your input. I agree that it’s not a big or unsolvable problem.
- jshier 4y agoOr 0, given not using dynamic dispatch allows for inlining or even the compiler optimizing the call away entirely.