samedi 21 octobre 2017

Is it a good idea to not use ember-data for performance reasons

Below are a couple of performance tests of Ember object creation.

Ember v2.3.1 with jQuery Snapshot of Ember v2.3.1 jsperf results

Ember v2.16.0 (latest as of the writing of this post) enter image description here

A couple of take-aways:

  1. Creating Ember objects is much slower than creating plain JS objects (about 100 times slower for Ember v2.3.1, and about 300 times slower for Ember v2.16.0)
  2. Ember v2.16.0 is slower than Ember v2.3.1 in terms of Ember object creation

I ran the perf tests repeatedly. The two above points were consistent across all my runs.

Now, suppose I want to create a new complex web UI using Ember. The UI needs to exchange a fair amount data (say, 100KB per http call) with backend frequently. Based on above performance results, and my assumption that ember-data needs to call a number of Ember.Object.create() per model, is it a good idea to not use ember-data in the app? One alternative will be just make ajax calls in model hook manually, and only create Ember object when it is necessary?

BTW, let's assume we have to use Ember in this scenario. The interesting question here is whether we can get performance gains by not using ember-data? Or, if we need to use ember-data for it's advantages, what are the usual optimizations we can do?




Aucun commentaire:

Enregistrer un commentaire