Test if same constructor always hidden class

JavaScript performance comparison

Test case created by pucelle

Preparation code

<script>
Benchmark.prototype.setup = function() {

  // Need to generate core of the benchmark dynamically to ensure
  // that type feedback does not leak between individual sample runs.
  var code = "for (var i = 0; i < N; i++) {" +
  "  var obj = arr[i];" + 
  "  result += obj.x + i;" + 
  "}" + 
  "return result";
  
  var f = new Function("N, arr, result", code);
  
  var objs = [];

  objs[0] = {x:1, y:1};
  objs[1] = {x:2, y:2};

  try{
 	abc = 1
  }
  catch(err){
  	delete objs[0].y
  	delete objs[0].x
  }

   try{
 	abc = 1
  }
  catch(err){
  	objs[0].x = 1
  }

  var mono = [],
      poly = []

  var N = 20;
  var result = 0;

  for (var i = 0; i < N; i++) {
    mono.push(objs[0])
    poly.push(objs[i % 2])
  }
};
          



Benchmark.prototype.teardown = function() {
     
  if (result < 0) throw "";
        
};
      
</script>
    
    

Preparation code output

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
calling monomorphic function
result = f(N, mono, result);
pending…
calling polymorphic
// polymorphic but with matching property offsets 
result = f(N, poly, result);
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