instantiation and method calling

JavaScript performance comparison

Test case created by picanteverde

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var fnAction = function(){
  	var i;
  	for(i = 0; i < 10; i += 1){
  	}
  };
  
  
  var PseudoClass = function(){
  
  };
  
  PseudoClass.prototype.action1 = fnAction;
  
  var PseudoSubClass = function(){
  
  };
  
  PseudoSubClass.prototype = new PseudoClass();
  
  PseudoSubClass.prototype.action2 = fnAction;
  
  var makeParasitic = function (){
  	return {
  		action1: fnAction
  	};
  };
  
  var makeSubParasitic = function(){
  	var o = makeParasitic();
  	o.action2 = fnAction;
  	return o;
  };

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