Test object creation

JavaScript performance comparison

Test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
constructor pattern
function A(y){
  this.x=y;
}

var sum=0;
for(var i=0;i<10000;i++){
  var a = new A(i);
  sum+=a.x;
}
console.log(sum);
pending…
object literal
var sum=0;
for(var i=0;i<10000;i++){
  var a = {x:i};
  sum+=a.i;
}
console.log(sum);
pending…
with additional attribute
var sum=0;
for(var i=0;i<10000;i++){
  var a = {x:i,y:3};
  fake=5;
  delete fake;
  sum+=a.i;
}
console.log(sum);
pending…
force no class creation
var sum=0;
for(var i=0;i<10000;i++){
  var a = {x:i,y:3};
  delete a.y;
  sum+=a.i;
}
console.log(sum);
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