Re: Cocoa optimization
Re: Cocoa optimization
- Subject: Re: Cocoa optimization
- From: j o a r <email@hidden>
- Date: Wed, 9 Nov 2005 10:37:50 +0100
On 9 nov 2005, at 10.28, David Hendrix wrote:
I've got an application where I'm seeing what looks like a great
deal of overhead when compared to good old "plain C" code. For
example, creating an NSString with [NSString stringWithFormat:...]
seems to take something like 5-10 times longer than a malloc/
sprintf combination. Of course some additional overhead is to be
expected with a truly object-oriented language, but I'm surprised
by the magnitude of the difference. I also wouldn't be worrying
about it except that this particular application needs to do this
(or similar) operations hundreds of thousands or millions of times.
The NS* functionality probably does a lot of things that you wouldn't
consider at first glance. To answer your question properly we also
need to know exactly what you mean when you say "malloc/sprintf".
Formatting strings in C is pretty tricky to do right. The
functionality provided by Cocoa probably tries to be secure and
correct, rather than blazing fast.
Have you tried to check what "+stringWithFormat:" is doing using
Shark? It will probably tell you all you need to know.
Have you looked at the functionality provided by CFString? It's
usually a bit faster than it's NS equivalent for performance critical
code.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden