obj vs arr access

Benchmark created on


Setup

function processObj(obj) {
	obj.a;
	obj.b;
}

function processArr(arr) {
	arr[0];
	arr[1]
}

Test runner

Ready to run.

Testing in
TestOps/sec
obj
processObj({a: 'a', b: 'b'});
processObj({a: 'a', b: 'b', c: 'c'});
processObj({a: 'a', b: 'b', c: 'c', d: 'd'});
processObj({a: 'a', b: 'b', c: 'c', d: 'd', e: 'e'});
//processObj({a: 'a', b: 'b', c: 'c', d: 'd', e: 'e', f: 'f'});
ready
arr
processArr(['a', 'b']);
processArr(['a', 'b', 'c']);
processArr(['a', 'b', 'c', 'd']);
processArr(['a', 'b', 'c', 'd', 'e']);
//processArr(['a', 'b', 'c', 'd', 'e', 'f']);
ready

Revisions

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