Looping

Benchmark created on


Setup

const len = 100000;
const items = [];
const out = Array.from({ length: len })

for (let i = 0; i < len; i++) {
	items.push(i + 1);
}

Teardown

delete foo;

Test runner

Ready to run.

Testing in
TestOps/sec
Raw
for (let i = 0; i < items.length; i++) {
	const item = items[i];
	out[i] = item;
}
ready
forEach
items.forEach((item, i) => {
  out[i] = item;
});
ready

Revisions

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