math float32 vs number

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 = 10000;
const f32 = new Float32Array(size); 
const nb = [];


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

Test runner

Ready to run.

Testing in
TestOps/sec
from f32 to f32
const out = new Float32Array(1);
for (let i = 0; i < size; ++i) out[0] *= f32[i];
ready
from f32 to nb
let out = 0;
for (let i = 0; i < size; ++i) out *= f32[i];
ready
from f32 to nb[]
let out = [0];
for (let i = 0; i < size; ++i) out[0] *= f32[i];
ready
from nb[] to nb
let out = 0;
for (let i = 0; i < size; ++i) out *= nb[i];
ready
from nb[] to nb[]
let out = [0];
for (let i = 0; i < size; ++i) out[0] *= nb[i];
ready
from nb[] to obj
const out = {a: 0};
for (let i = 0; i < size; ++i) out.a *= nb[i];
ready
from f32 to obj
const out = {a: 0};
for (let i = 0; i < size; ++i) out.a *= f32[i];
ready

Revisions

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