operator functions

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function internalTestFunction() {
      this.property += Math.random();
    }
   
    function externalTestFunction(object) {
      object.property += Math.random();
    }
   
    function prototype_constructor() {
      this.property = Math.random();
    };
   
    window.pp = prototype_constructor;
   
    prototype_constructor.prototype = {
      testFunction: internalTestFunction
    };
   
    function object_constructor() {
      this.property = Math.random();
      this.testFunction = internalTestFunction;
    };
   
    function external_constructor() {
      this.property = Math.random();
    }
   
    var prototype_suit = [];
    var object_suit = [];
    var external_suit = [];
    var n = 100;
    while (n--) {
      prototype_suit.push(new prototype_constructor);
      object_suit.push(new object_constructor);
      external_suit.push(new external_constructor);
    }
};
</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
Prototype
var n = 100;
while (n--) {
  prototype_suit[n].testFunction();
}
pending…
Object
var n = 100;
while (n--) {
  object_suit[n].testFunction();
}
pending…
External
var n = 100;
while (n--) {
  externalTestFunction(external_suit);
}
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