3 ms·
They aren't are they? Cached method calls are fairly fast from what i've read. [1] https://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-
by Alphasite_ 11y ago
They aren't are they? Cached method calls are fairly fast from what i've read.
[1] https://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-leopard-edition.html https://www.mikeash.com/pyblog/performance-comparisons-of-co...
- pcwalton 11y agoAccording to that chart, Obj-C method calls are either 4.5x or 7.8x slower than C++ virtual method calls, depending on whether you're looking at 32- or 64-bit code. That alone is pretty bad. But it's even worse than that: I'm talking about devirtualized calls, which are far faster than virtual calls in C++. More importantly than just the call time, devirtualization can have outsized performance impact because it enables inlining, converting intraprocedural optimizations to interprocedural optimizations. The difference between inlining and not can easily be a 10x-level performance difference with an optimizing compiler like LLVM.
- mpweiher 11y agoThe chart is wrong for message sends. I've been measuring this for a long time, and get ~2.1ns for a message send vs. 1.2ns for a cached message send on a comparable machine. If you want inlining, use a static inline function.