Ruud's Test a/b

JavaScript performance comparison

Test case created

Preparation code

<script src="http://dev.groowup.nl/test/mootools-core-1.4.5-full-nocompat.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var TestA = new Class({
   
      Implements: Events,
   
      initialize: function() {
   
        this.addEvent("run", this._run.bind(this));
      },
      _run: function() {
        return "jaa";
      }
   
    });
   
    var TestB = new Class({
   
      Implements: Events,
   
      initialize: function() {
        var self = this;
        this.addEvent("run", function() {
          self._run();
        });
      },
      _run: function() {
        return "jaa";
      }
   
    });
   
    var instancesA = [], instancesB = [];
   
    for( var i = 0; i < 100; i++ )
    {
    instancesA[instancesA.length] = new TestA();
    }
   
    for( var i = 0; i < 100; i++ )
    {
    instancesB[instancesB.length] = new TestB();
    }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Test A
// async test
instancesA[Math.round(Math.random()*99)].fireEvent("run");
pending…
Test B
// async test
instancesB[Math.round(Math.random()*99)].fireEvent("run");
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment