exoskeleton vs backbone events

JavaScript performance comparison

Revision 6 of this test case created by cletus

Preparation code

<script src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.underscore.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js'></script>
<script>var bbEvents = Backbone.Events;</script>
<script>var extend = _.extend; window._ = null;</script>
<script src="https://github.com/paulmillr/exoskeleton/releases/download/0.6.3/exoskeleton.js"></script>
<script>var exosEvents = Exoskeleton.Events;</script>
      
<script>
Benchmark.prototype.setup = function() {
  var numEvents = 3;
  var numListeners = 100;
  var bb = extend({x:0}, bbEvents);
  var exos = extend({x:0}, exosEvents);
  
  [bb, exos].forEach(function(obj) {
    obj.on('event1', function() { obj.x++; });
    obj.on('event2', function() { obj.x++; });
    obj.off();
  });

};
</script>

Preparation code output

<script src='//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js'></script> <script>var bbEvents = Backbone.Events;</script> <script>var extend = _.extend; window._ = null;</script> <script src="https://github.com/paulmillr/exoskeleton/releases/download/0.6.3/exoskeleton.js"></script> <script>var exosEvents = Exoskeleton.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
Exoskeleton
var a, b, c, i;
for (i = 0; i < 100; i++) {
  a = Math.random() * 5;
  b = Math.random() * 10;
  c = Math.random() * 20;
  exos.trigger('event' + i, a, b);
}
pending…
Backbone
var a, b, c, i;
for (i = 0; i < 100; i++) {
  a = Math.random() * 5;
  b = Math.random() * 10;
  c = Math.random() * 20;
  bb.trigger('event' + i, a, b);
}
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