Creating many Ember.Object's

Hi,

It looks like Ember.Object.create is much slower then creating a plain JS object (obviously). I find it to be up to 100 times slower (!), depending on the number of properties passed to create().

Is there a faster way to convert an array of json objects to Ember objects, other then iterating the array and calling Ember.Object.create?

In general, there is no reason to create Ember.Object’s if you do not need Ember.Object functionality.

A plain JS object will work fine from templates and whatnot if you use Ember.get and Ember.set.

Demo: Ember Twiddle


That being said, you would need to determine if this makes sense in your scenario. It seems like you would need to create quite a few objects for this to add up to anything important…

1 Like

Thanks! What do you mean by: “Ember.Object functionality”?

What about computed-properties?

Actually, in my scenario my objects are a bunch of plain properties, plus some Ember.computed.readOnly properties… would you say I “need the Ember.Object functionality”?

I have about 10,000 objects, and it takes about 300 ms… it’s noticeable…

BTW, using a production build does help a bit (about a factor of 2, in my tests)

I would also like to ask for this feature. I have created a jsPerf to show how bad this problem is, particularly with arrays: http://jsperf.com/ember-object-creation-speed . In my case we convert native objects to their ember counterparts in order to add computed properties much like this other gentleman.