speed, Foundation vs. Core Foundation - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: speed, Foundation vs. Core Foundation (/thread-5411.html)
speed, Foundation vs. Core Foundation - Andrew - Jun 14, 2005 11:05 PM
I recently wrote a HUGE objective-C class which makes extensive use of NSDictionary and NSArray (as well as their mutable counterparts). Some of the methods are quite long. I'm quite happy with how quickly the codes runs, but I'm wondering if I could push it to execute even faster.
How much performance gain do you think I'll see if I were to switch from using NS* to CF* inside my larger methods? Since the Foundation classes are implemented in C (due to the whole toll-free bridge thing), I'm guess the only thing I'd be saving would be the time extra time it takes to invoke an objective-C method (as opposed to calling a C function).
Given that some of my larger methods make many hundreds of calls to Foundation storage objects, I figure it might be worth the trouble to convert from a Foundation based implementation to a Core Foundation based one.
speed, Foundation vs. Core Foundation - OneSadCookie - Jun 14, 2005 11:10 PM
The pain of those CF function names isn't worth it if it's running fast enough already
speed, Foundation vs. Core Foundation - Andrew - Jun 14, 2005 11:24 PM
ya, CF is kind of awkward... my code already contains quite a bit of CF in it because it deals with HID Manager, so I've gotten used to API. I initially found it quite frustrating that many of the function calls take many more parameter than their objective-C cousins.
I guess I'm just looking for a ballpark figure... 10%? 20%?
speed, Foundation vs. Core Foundation - OneSadCookie - Jun 14, 2005 11:26 PM
Shark it and find out how much time you're wasting in ObjC method dispatch overhead. There's no substitute for profiling.
speed, Foundation vs. Core Foundation - Andrew - Jun 15, 2005 12:00 AM
OneSadCookie Wrote:Shark it and find out how much time you're wasting in ObjC method dispatch overhead. There's no substitute for profiling.
Done and done
Shark shows that this
only takes up 0.2% of the total CPU time, and that's the most CPU hungry Foundation call it lists!
So, as always (), you're right Keith... it would be a total waste of time to convert the code to CF
speed, Foundation vs. Core Foundation - Fenris - Jun 15, 2005 05:07 AM
When this discussion comes up, I always relate the best story I ever experienced on this matter. I was asked to port a physics-intensive FPS engine to the Mac, which ran more than 20 times slower than on a PC with about the same specs. So, FPS engine... physics intensive... what could slow that down? 3D rendering, of course. Physics calculations. Skeletal animation?
Well, no. It was a really really stupid function that compared two strings. Once I substituted that slow and overkilling function, the Mac version ran at 1.5 times the speed of the PC version. Shark is your friend, always.