Re: cocoa bindings performance
Re: cocoa bindings performance
- Subject: Re: cocoa bindings performance
- From: Mike Abdullah <email@hidden>
- Date: Sun, 17 Feb 2013 13:54:06 +0000
Sent from my iPad
On 15 Feb 2013, at 19:42, Maximilian Marcoll <email@hidden> wrote:
>
> Hi everyone!
>
> I have a problem with bindings, or so it seems.
>
> In my application, I need to programmatically create lots of small views embedded in a big view.
> Think of them as draggable items on a plane.
>
> Thus far I'm controling the views using bindings. Four bindings per view to be precise.
> The bindings bind the views to controller objects, which are connected to my model objects.
> The bindings are used to change the model objects' values according to their size and their position on the plane and vice versa.
>
> If I the app has to manage only a small number of items everything works fine.
> But when there are very many items (views) to create, the app slows down considerably and is basically unuseable.
>
> I assumed that I somehow wrote very unefficient code in my views or something like that and I used the Time Profiler to see what actually is the most time consuming operation.
> It appears that the method consuming 90% of the time is:
> -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] .
Ok, and what inside of this method is taking up the time?
In my experience the act of creating or tearing down a lot of observations is pretty slow; can you avoid making so many bindings in one go? Perhaps recycle existing bindings rather than recreating anew?
Secondly, what do your model objects inherit from? If they're direct NSObject subclasses, an easy win for KVO performance is to implement -setObservationInfo: and getter method too.
>
> Now, I'm obviously missing something here. What I want is to have lots of small rectangular items on a plane.
> Hundreds, or even thousands of them.
> I want to be able to drag them around, change their size and have those properties change values in my model.
>
> It seems very unlikely to me that creating bindings for those views is actually that time consuming by itself.
> Or is it?
>
> Any help is much appreciated!
>
> Thank you!!
>
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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