• 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: Repetitive Appending of Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repetitive Appending of Strings


  • Subject: Re: Repetitive Appending of Strings
  • From: Chris Suter <email@hidden>
  • Date: Wed, 13 Feb 2008 10:49:59 +1100


On 13/02/2008, at 10:25 AM, Adam P Jenkins wrote:

Yeah, it was about 0.007 seconds without the reserve() call, but since I was doing the equivalent of reserve with the NSMutableData case, it seems more even to do the same with the vector<char> case.

As for clear(), I tried changing the code to use the swap trick you showed, and the timing results were the same. I don't understand why the vector[i]=ch example runs faster than the raw array access example. It must just be an artifact of some allocation and caching behavior. I'm fine with just calling them the same.

In any case it shows that for small methods where you don't actually need dynamic dispatch, C++'s inlining and non-virtual methods can yield much faster code than you can get with Objective-C classes.

Adam

I did point this out off-list, but I think it's worth mentioning it to the list. I personally would be wary about these results because I think they're too small. Time-slicing on OS X is the order of tens of milliseconds (I believe) so a context switch could put these results out.


Furthermore, the first two tests use format strings whilst the others don't. I'd also worry about how one test was interacting with the next test.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: "Michael Ash" <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)

  • Prev by Date: Re: Crash at THFSPlusStore::LessThan(HFSUniStr255 const&)
  • Next by Date: Re: NSView -drawRect optimization
  • Previous by thread: Re: Repetitive Appending of Strings
  • Next by thread: Re: Repetitive Appending of Strings
  • Index(es):
    • Date
    • Thread