object speeds

Benchmark created on


Description

compare the different ways of making an object.

Test runner

Ready to run.

Testing in
TestOps/sec
json
var obj1 = {}
obj1.a = 1000;
obj1.b = function(){
  obj1.a * 1000;
}
obj1.b();
ready
json enclosed
var obj2 = {
  a: 1000,
  b: function(){
    this.a*1000;
  }
}
obj2.b();
ready
function with enclosed definitions
function obj3(){
  this.a  = 1000;
  this.b = function(){
    this.a*1000;
  }
}
var test = new obj3();
test.b();
ready
function with prototype
function obj4(){};
obj4.prototype.a  = 1000;
obj4.prototype.b = function(){
  this.a*1000;
}
var test = new obj4();
test.b();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.