Re: Problems with Key Observing Registration Performance
Re: Problems with Key Observing Registration Performance
- Subject: Re: Problems with Key Observing Registration Performance
- From: Markus Spoettl <email@hidden>
- Date: Tue, 9 Sep 2008 18:48:05 -0700
On Sep 9, 2008, at 5:28 PM, Markus Spoettl wrote:
These numbers come from a test case with 140 objects, when I double
the object number, the test never finishes (at least not within 10
minutes).
OK, I did some more testing and timing and there is a solution - which
I don't understand:
Testing with 326 objects, adding each of the objects to the array like
this
NSMutableArray *kvoArray = [self mutableArrayValueForKey:@"array"];
for (MyObject *obj in inputData) {
[kvoArray addObject:newObject];
}
This takes 580 seconds. Each add causes a chain reaction of events
that eventually adds a new NSView to the collection view. I've
experimented with setting the whole array at once using -setArray: but
that does not make any difference.
However, adding an auto-release pool does make a huge difference:
NSMutableArray *kvoArray = [self mutableArrayValueForKey:@"array"];
for (MyObject *obj in inputData) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[kvoArray addObject:newObject];
[pool release];
}
The same operation now takes 60 seconds. That's 10% of the original
time.
What I don't understand is why adding the auto-release pool has such a
dramatic impact on registering observers on the objects. Anyone know
why?
Regards
Markus
--
__________________________________________
Markus Spoettl
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