js-array-beercss (v4)

Revision 4 of this benchmark created on


Setup

const list = [];
for(let i=0; i<10000; i++) list.push(i);

Test runner

Ready to run.

Testing in
TestOps/sec
for of
let sum = 0;
for(let item of list) sum += item;
console.log(sum);
ready
for i
let sum = 0;
for(let i=0; i<list.length; i++) sum += list[i];
console.log(sum);
ready
for i, n
let sum = 0;
const n = list.length;
for(let i=0; i<n; i++) sum += list[i];
console.log(sum);
ready
forEach
let sum = 0;
list.forEach(item => sum += item);
console.log(sum);
ready

Revisions

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