Events vs Events2

JavaScript performance comparison

Revision 19 of this test case created

Preparation code

<script src='https://raw.github.com/documentcloud/underscore/master/underscore.js'></script>
<script src='https://raw.github.com/documentcloud/backbone/a5ddc18/backbone.js'></script>
<script>var masterEvents = Backbone.Events;</script>
<script src='https://raw.github.com/documentcloud/backbone/103c9e8/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

Test runner

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

Java applet disabled.

Testing in unknown unknown
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. Here’s a list of current revisions for this page:

0 comments

Add a comment