Backbone Events

JavaScript performance comparison

Revision 22 of this test case created

Preparation code

<script src='//code.jquery.com/jquery-1.9.1.min.js'></script>
<script src='//raw.github.com/documentcloud/underscore/master/underscore.js'></script>
<script src='//raw.github.com/documentcloud/backbone/0.5.3/backbone.js'></script>
<script>var bb53Events = Backbone.Events;</script>
<script src='//raw.github.com/documentcloud/backbone/0.9.2/backbone.js'></script>
<script>var bb92Events = Backbone.Events;</script>
<script src='//raw.github.com/documentcloud/backbone/0.9.10/backbone.js'></script>
<script>var bb910Events = Backbone.Events;</script>
<script src='//raw.github.com/documentcloud/backbone/master/backbone.js'></script>
<script>var bbMasterEvents = Backbone.Events;</script>
<script>
Benchmark.prototype.setup = function() {
    var jq = jQuery({});
    var bb53 = _.extend({}, bb53Events);
    var bb92 = _.extend({}, bb92Events);
    var bb910 = _.extend({}, bb910Events);
    var bbMaster = _.extend({}, bbMasterEvents);
   
    var numEvents = 3;
    var numListeners = 100;
    var objs = [jq, bb53, bb92, bb910, bbMaster];
   
    _.times(numEvents, function (n) {
      _.times(numListeners, function () {
        _.invoke(objs, 'bind', 'event' + n, function () {});
      });
    });
};
</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
jQuery 1.9.1
for (var i = 0; i < numEvents; i++) {
  jq.trigger('event' + i, 1, 2, 3);
}
pending…
Backbone 0.5.3
for (var i = 0; i < numEvents; i++) {
  bb53.trigger('event' + i, 1, 2, 3);
}
pending…
Backbone 0.9.2
for (var i = 0; i < numEvents; i++) {
  bb92.trigger('event' + i, 1, 2, 3);
}
pending…
Backbone 0.9.10
for (var i = 0; i < numEvents; i++) {
  bb910.trigger('event' + i, 1, 2, 3);
}
pending…
Backbone Master
for (var i = 0; i < numEvents; i++) {
  bbMaster.trigger('event' + i, 1, 2, 3);
}
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