summarizators (v3)

Revision 3 of this benchmark created on


Setup

// the seconds of a day (86000) multiplied by 100
const ARRAY_SIZE = 8600000; 
const elements = Array.from({ length: ARRAY_SIZE }).map((item, index) => ({ index, height: 120 }));

Test runner

Ready to run.

Testing in
TestOps/sec
while
let total = 0;
let i = 0;
while (i < elements.length) {
  total += elements[i].height;
  i++;
}
return total;
ready
for
let total = 0;
let i = 0;
for (i; i < elements.length; i++) {
  total += elements[i].height;
}
return total;
ready
reduce
return elements.reduce((total, item) => total + item.height, 0);
ready
forEach
let total = 0;
elements.forEach((item) => total += item.height);
return total;
ready

Revisions

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