instantiation and method calling

JavaScript performance comparison

Revision 5 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var fnAction0 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  
  var fnAction1 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction2 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction3 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction4 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction5 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction6 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction7 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction8 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var fnAction9 = function(){
  	var i, l;
      for( i = 0, l = 10000 ; i < l ; ++i ) {};
  };
  
  var PseudoClass = function(){};
  
  PseudoClass.prototype.action0 = fnAction0;
  PseudoClass.prototype.action1 = fnAction1;
  PseudoClass.prototype.action2 = fnAction2;
  PseudoClass.prototype.action3 = fnAction3;
  PseudoClass.prototype.action4 = fnAction4;
  PseudoClass.prototype.action5 = fnAction5;
  PseudoClass.prototype.action6 = fnAction6;
  PseudoClass.prototype.action7 = fnAction7;
  PseudoClass.prototype.action8 = fnAction8;
  PseudoClass.prototype.action9 = fnAction9;
  
  var PseudoSubClass = function(){};
  
  PseudoSubClass.prototype = new PseudoClass();
  
  
  
  PseudoSubClass.prototype.action20 = fnAction0;
  PseudoSubClass.prototype.action21 = fnAction1;
  PseudoSubClass.prototype.action22 = fnAction2;
  PseudoSubClass.prototype.action23 = fnAction3;
  PseudoSubClass.prototype.action24 = fnAction4;
  PseudoSubClass.prototype.action25 = fnAction5;
  PseudoSubClass.prototype.action26 = fnAction6;
  PseudoSubClass.prototype.action27 = fnAction7;
  PseudoSubClass.prototype.action28 = fnAction8;
  PseudoSubClass.prototype.action29 = fnAction9;
  
  var makeParasitic = function (){
  	var o = {};
  
  	o.action0 = fnAction0;
  	o.action1 = fnAction1;
  	o.action2 = fnAction2;
  	o.action3 = fnAction3;
  	o.action4 = fnAction4;
  	o.action5 = fnAction5;
  	o.action6 = fnAction6;
  	o.action7 = fnAction7;
  	o.action8 = fnAction8;
  	o.action9 = fnAction9;
  
  	return o;
  };
  
  var makeSubParasitic = function(){
  	var o = makeParasitic();
  
  
  	o.action20 = fnAction0;
  	o.action21 = fnAction1;
  	o.action22 = fnAction2;
  	o.action23 = fnAction3;
  	o.action24 = fnAction4;
  	o.action25 = fnAction5;
  	o.action26 = fnAction6;
  	o.action27 = fnAction7;
  	o.action28 = fnAction8;
  	o.action29 = fnAction9;
  
  		
  	
  	return o;
  };
  
  var pseudoObject = new PseudoSubClass();
  var parasiticObject = makeSubParasitic();

};
</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
PseudoClass
var o = new PseudoSubClass();
o.action1();
o.action29();
pending…
ParasiticClass
var o = makeSubParasitic();
o.action1();
o.action29();
pending…
PseudoClass stress prototypechain
var o = new PseudoSubClass();
var i, l;
for (i=0, l = 500; i<l; i++){
  o.action0();
  o.action29();
}
pending…
ParasiticClass stress action2
var o = new makeSubParasitic();
var i, l;
for (i=0, l = 500; i<l; i++){
  o.action0();
  o.action29();
}
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