Re: Repetitive Appending of Strings
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