cocoa bindings performance

2013-02-17 Thread Maximilian Marcoll

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:] .

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 (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


Re: cocoa bindings performance

2013-02-17 Thread Tom Davie
Sorry I can't be of more direct help, but…

Cocoa bindings are unfortunately one of many tools that apple produces with the 
thought we can make this small task I do repeatedly much easier in their 
head, that typically doesn't cover the general case.  They're enormously 
productive if all you're doing is one of the obvious, standard UIs.  
Unfortunately, as soon as you want to do something more complex, that typically 
breaks down with almost any structure.  This is due to 3 things:
1) Debugging them is near impossible – you end up wasting as much time as you 
save trying to track down what's wrong.
2) Lack of flexibility – you eventually hit a wall where bindings simply can't 
do what you want any more and need to rewrite everything.
3) Performance – you can't tune anything with these technologies typically.

My advice would simply be to steer well clear of bindings (along with a couple 
of other techs that supposedly make life easier, like CoreData and Storyboards).

Thanks

Tom Davie

On 15 Feb 2013, at 19:42, Maximilian Marcoll m...@dis.playce.info 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:] .
 
 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 (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/tom.davie%40gmail.com
 
 This email sent to tom.da...@gmail.com


___

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

Re: cocoa bindings performance

2013-02-17 Thread Mike Abdullah


Sent from my iPad

On 15 Feb 2013, at 19:42, Maximilian Marcoll m...@dis.playce.info 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 (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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

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