Backbone get

JavaScript performance comparison

Revision 5 of this test case created by Drew

Preparation code

<script src='http://code.jquery.com/jquery.js'></script>
<script src='http://underscorejs.org/underscore.js'></script>
<script src='http://backbonejs.org/backbone.js'></script>

      
<script>
Benchmark.prototype.setup = function() {
  var User = Backbone.Model.extend({});
  var user = new User;
  var props = { a: "sth" };
  
  user.set(props);
  user.props = props;
  
  var s;

};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Backbone get

  s = user.get('a');
pending…
Backbone attrs

  s = user.attributes.a;
pending…
Backbone attrs 2

  s = user.attributes['a'];
pending…
native get

  s = user.props.a;
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.

0 Comments