Ember object vs normal object vs Backbone.Model object

JavaScript performance comparison

Revision 3 of this test case created by Josh Vermaire

Info

Test how much is the overhead for creating an Ember-object vs Normal Object vs Backbone.Model object.

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.4.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.0/backbone-min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    window.array = [];
    myModel = Backbone.Model.extend({
      defaults: {
        foo: "bar",
        fizz: "buzz",
        a: 1,
        b: 2
      }
    })
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Create SC.Objects
array.push(SC.Object.create({
  foo: "bar",
  fizz: "buzz",
  a: 1,
  b: 2
}));
pending…
Create Javascript objects
array.push({
  foo: "bar",
  fizz: "buzz",
  a: 1,
  b: 2
});
pending…
Create Backbone.Model objects
array.push(Backbone.Model.extend({
  defaults: {
    foo: "bar",
    fizz: "buzz",
    a: 1,
    b: 2
  }
}));
pending…
Create new empty instance of myModel
array.push(new myModel());
pending…
Create new instance of myModel
array.push(new myModel({
    foo: "barbar",
    fizz: "buzzed",
    a: 3,
    b: 4
  }));
pending…
Create new instance of Backbone.Model
array.push(new Backbone.Model({
    foo: "barbar",
    fizz: "buzzed",
    a: 3,
    b: 4
  }));
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment