> With only 350 objects you should be fine using a ‘dumb’ archived dictionary. 
> I’ve used that approach for several thousand objects that were more complex 
> than cookies; this was on a Mac, but it was back in 2004 so it was probably 
> slower than today’s iPhones ;-)
> 
>> I detect the performance issue using Instruments to mesure CPU time. The
>> heaviest call from my call resulted to [CookieKey encodeWithCoder:]
> 
> That method should be pretty quick, so if it’s taking a lot of time there may 
> be too many calls to it.
> 
> My guess is that you’re saving the ‘database’ to disk after every single 
> change. That’s going to take O(n^2) time to add n entries, and I can believe 
> it would be noticeably slow to add 350. Try doing what I said in my last 
> message, using a time delay before saving.


I would agree with what Jens says here - the problem isn’t using keyed 
archiving, but the way you’re using keyed archiving.

I sometimes save tens of thousands of objects using keyed archiving and it’s 
not slow. While that’s on Mac not iOS, the difference shouldn’t be important. 
At one time I did run into performance issues with very large numbers of 
objects, but that turned out to be mostly to do with dearchiving which called a 
property setter for each property (some of which had side-effects) rather than 
directly setting the backing store for the property. If you’re using automatic 
backing store synthesis, there’s probably not much you can do about that, but 
you’d want to be definitely sure that was the problem before doing anything 
about it anyway.

Sounds like there is plenty of scope for improving performance in your design 
without changing from keyed archving or needing to look at direct propery 
access. The problem seems to be in your higher-level code that is managing the 
saving to disk of the archives you create.

—Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to