object accesses

Benchmark created on


Setup

var limit = 100;
var arr = [];
var obj = [];
for (var i = 0; i < limit; i++){
	var a = Math.random();
	var b = {wah:"1223"};
	var c = "shit my ass";
	arr.push([a,b,c]);
	obj.push({a:a, b:b, c:c});
}

Test runner

Ready to run.

Testing in
TestOps/sec
obj perf
var acc = 0;
for (var i = 0; i < limit; i++){
	var idx = Math.floor(Math.random()*limit);
	var o = obj[o];
	acc += o.a+o.b.wah.length + o.c.length;
}
ready
array perf
var acc = 0;
for (var i = 0; i < limit; i++){
	var idx = Math.floor(Math.random()*limit);
	var a = arr[o];
	acc += a[0]+a[1].wah.length + a[2].length;
}
ready

Revisions

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