Backbone get

JavaScript performance comparison

Revision 6 of this test case created by Henry Zou

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" };
    var attrs = user.attributes;
   
    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 unknown unknown
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…
local variable backbone.attrs
  s = attrs.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. Here’s a list of current revisions for this page:

0 comments

Add a comment