• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Cocoa optimization
      • From: David Hendrix <email@hidden>
References: 
 >Cocoa optimization (From: David Hendrix <email@hidden>)

  • Prev by Date: Cocoa optimization
  • Next by Date: Re: Cocoa optimization
  • Previous by thread: Cocoa optimization
  • Next by thread: Re: Cocoa optimization
  • Index(es):
    • Date
    • Thread