Performance questions / tips for bindings

Hi enyo masters,

A couple of questions on bindings and their performance.

1. Is it better to have one binding that sets content and classes on many objects via its transform function, or is it better to have multiple individual bindings to content and classes.

For example:
bindings:[
{from:".model", to:".null", transform: function(v,d,b){

if (!v){return}
var raw = v.raw();
this.$.name.setContent(v.name);
this.$.name.addClass(v.name);
(plus 20 more setters!)

return;
}}]
vs
bindings:[
{from:".model.name", to:".$.name.content"},
{from:".model.name", to:".$.name.classes"},
{+ 20 more bindings}
]

2. does removing the "." in front of path really have a significant performance impact for approximately 200-300 bindings?

Thanks!
Cage

Comments

  • Are you discovering poor performance using individual bindings?
  • I have discovered poor performance but it may or may not be due to individual bindings :) Hence the question before I embark on a major code rewrite with regards to bindings (i.e., if there's not going to be much of a performance difference, maybe I should be looking somewhere else in my code!)
  • There is overhead with bindings; nothing is free after all. I'd suggest doing some profiling to see where time is being spent before refactoring. If you discover the quantity of bindings is an issue (tell us!), I'd suggest using a single observer on your kind rather than a binding transform to do the data mapping.
  • Bindings do have to explicitly remove the '.' if it's there. So, it is overhead. Best to fix it statically.
Sign In or Register to comment.