math float32 vs number (v4)

Revision 4 of this benchmark created on


Description

Trying to multiply numbers coming from a number array or a float32 array ; and storing the result to a var, a float32array, a number array or an object

Setup

const size = 100000;
const f32 = new Float32Array(size *2); 
const nb = [];

for (let i = 0; i < size *2; ++i) nb[i] = f32[i] = Math.random();

const outf32 = new Float32Array(size);
const outNb = [];
outNb.length = size;
for (let i = 0; i < size; ++i) nb[i] = 0;

Teardown

console.log(outNb, outf32);

Test runner

Ready to run.

Testing in
TestOps/sec
from f32 to f32
for (let i = 0; i < size; ++i) {
	const i2 = i*2;
	outf32[i] = f32[i2] * f32[i2+1];
}
ready
from f32 to nb
for (let i = 0; i < size; ++i) {
	const i2 = i*2;
	outNb[i] = f32[i2] * f32[i2+1];
}
ready
from nb to nb
for (let i = 0; i < size; ++i) {
	const i2 = i*2;
	outNb[i] = nb[i2] * nb[i2+1];
}
ready
from nb to f32
for (let i = 0; i < size; ++i) {
	const i2 = i*2;
	outf32[i] = nb[i2] * nb[i2+1];
}
ready

Revisions

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