accessors

Benchmark created on


Setup

const arr = [...Array(256).keys()];
const arr8 = new Uint8Array(arr);
const map = arr.reduce((a,c) => { a.set(c, c); return a }, new Map());
const obj = arr.reduce((a,c) => { a[c] = c; return a }, {});
const dataView = new DataView(arr8.buffer);

Test runner

Ready to run.

Testing in
TestOps/sec
access array at index
let i = 255;
while (i) {
	arr[i];
	i--;
}
ready
access typed array at index
let i = 255;
while (i) {
	arr8[i];
	i--;
}
ready
access map at index
let i = 255;
while (i) {
	map.get(i);
	i--;
}
ready
access buffer through dataView
let i = 255;
while (i) {
	dataView.getUint8(i);
	i--;
}
ready
access object by key
let i = 255;
while (i) {
	obj[i];
	i--;
}
ready

Revisions

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