Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

According to the link you posted, that's over four times slower than C++ virtual method dispatch (and note that most method calls in ordinary C++ code are not virtual). Also, IMP caching is hardly easy and is quite fiddly: see for example the benchmark code in that link as well as [1].

I highly recommend reading the tour of objc_msgSend [2]. It's very eye opening: for example, there's a cache scanning loop even in the fast case.

[1]: http://www.mulle-kybernetik.com/artikel/Optimization/opti-3-... [2]: http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-th...



>According to the link you posted, that's over four times slower than C++ virtual method dispatch

Hmm, check the results in the same page for the 64bit Cocoa runtime. This is where most optimizations are made, because Apple used the 32->64 bit transition as an opportunity to do most binary compatibility breaking changes to the language.

There, in 64bit, the IMP cached msg send is actually FASTER than C++ virtual method dispatch.

And if your app's performance suffers because of method calls / msg sends, you are doing it wrong. They should be an insignificant amount of time compared to the actual processing stuff done by your app.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: