js-array-beercss (v2)

Revision 2 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;
for(let i=0, n=list.length; 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.