loop test (v2)

Revision 2 of this benchmark created on


Setup

const items = new Array(1000).fill(1)

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
let sum = 0;
for (let i = 0; i < items.length; i++) {
	sum += items[i];
}
ready
while
let sum = 0;
let i = items.length
while (i--) {
	sum += items[i];
}
ready
forEach - arrow func
let sum = 0;
items.forEach((item) => {
	sum += item;
})
ready
reduce
const sum = items.reduce((acc, item) => acc + item)
ready

Revisions

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