Events vs Events2

JavaScript performance comparison

Revision 20 of this test case created by

Preparation code

<script src='https://raw.github.com/documentcloud/underscore/master/underscore.js'></script>
<script src='https://raw.github.com/documentcloud/backbone/master/backbone.js'></script>
<script>var masterEvents = Backbone.Events;</script>
<script src='https://raw.github.com/caseywebdev/backbone/events/backbone.js'></script>
<script>var caseyEvents = Backbone.Events;</script>
      
<script>
Benchmark.prototype.setup = function() {
  master = _.extend({}, masterEvents);
  casey = _.extend({}, caseyEvents);
  
  numEvents = 3;
  numListeners = 100;
  
  _.times(numEvents, function(event) {
    _.times(numListeners, function() {
      master.on("event" + event, function(){});
      casey.on("event" + event, function(){});
    });
  });

};
</script>

Preparation code output

<script src='https://raw.github.com/documentcloud/backbone/master/backbone.js'></script> <script>var masterEvents = Backbone.Events;</script> <script src='https://raw.github.com/caseywebdev/backbone/events/backbone.js'></script> <script>var caseyEvents = Backbone.Events;</script>

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
master
for (var i = 0; i < numEvents; i++) {
  master.trigger('event' + i, 1, 2, 3);
}
pending…
casey
for (var i = 0; i < numEvents; i++) {
  casey.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.

0 Comments