[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C and Smalltalk; speed of message send

From: Marcel Weiher
Subject: Re: Objective-C and Smalltalk; speed of message send
Date: Wed, 18 Aug 2004 20:49:52 +0100

Hi Travis!

Do real world examples count then?


For a while we've considered porting a straight C processing application upward into Objective-C. One of the things we wanted to do was use a Dictionary (NSMutableDictionary) to store arbitrarily keyed tallies. This would replace an existing 2D array in strict C.

Whoa, an NSDictionary is a pretty heavy-weight item, especially compared to a simple 2D array! Why not stick with the 2D array, if I may ask? After all, one of the point of Objective-C is that it *is* C.

 We decided to use NSStrings as the keys.

Also potentially fairly heavy, though a common choice. I remember people complaining about NSString's performance compared to char* when Foundation was introduced. However, NSString is really for "human readable" text, whereas char* is often more for "tokens", or really just byte-sequences.

To maintain a backwards bridge, we took the old 2D access indices and turned them into a string. And then stored/set them in the NSMutableDictionary via those. The performance was not impressive.

I wouldn't expect it to be. NS(Mutable)Dictionary is pretty slow. One issue is that it copies its keys. Arrrggghh.

 I got some pointers from this mailing list, which improved things.

What were the suggestions?

In the end, we'd squeezed out a solution which was almost 50% of the speed what VisualWorks Smalltalk did the same task in. The Smalltalk one was still 2x faster though, i never had to think about the memory management issues, and it worked the first time.

No complaints about Smalltalk from me :-))

That aside, I'm still a huge Objective-C fan, and we may still go that route anyway. We're not sure how to get our semi-realtime data into/outof the Smalltalk memory model fast enough. :)

Yep, the really great thing about Objective-C is its connectivity.



Marcel Weiher                           Metaobject Software Technologies
address@hidden          www.metaobject.com
Metaprogramming for the Graphic Arts.   HOM, IDEAs, MetaAd etc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]