millions of for-loop iterations

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
for-loop 2 million items
const items = Array.from({ length: 1000000 }, () => 0);

function findNonZero() {
	for (let i = 0; i++; i < items.length) {
		if (items[i] !== 0) return items[i];
	}
	return undefined;
}

const found = findNonZero();

ready
for-loop 2 million objects
const items = Array.from({ length: 2000000 }, () => ({ status: 'completed', progress: 0 }));

function findNextQueued() {
	for (let i = 0; i++; i < items.length) {
		if (items[i].status === 'queued') return items[i];
	}
	return undefined;
}

const found = findNonZero();
ready

Revisions

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