Array vs Float32Array vs object

Benchmark created on


Description

Compare Array vs Float32Array vs object per

Setup

for (let i = 0; i < 1_000_000; i++) {
	const a = new Float32Array(2);
	const b = [0, 0];
	const c = {x: 0, y: 0};
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array
const _b = [0,0];

for (let i = 0; i < 1_000_000; i++) {
	_b[0] = Math.random();
	_b[1] = Math.random();
}
ready
Float32Array
const _a = new Float32Array(2);

for (let i = 0; i < 1_000_000; i++) {
	_a[0] = Math.random();
	_a[1] = Math.random();
}
ready
Object
const _c = {x: 0, y: 0};

for (let i = 0; i < 1_000_000; i++) {
	_c.x = Math.random();
	_c.y = Math.random();
}
ready

Revisions

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