filter of for if

Benchmark created on


Setup

const randomArray = Array.from({ length: 10000 }, () => Math.random() * 1000);

Test runner

Ready to run.

Testing in
TestOps/sec
for if
for (const i of randomArray) {
	if (i > 300) {
		console.log('COUCOU')
	}
}
ready
filter
for (const i of randomArray.filter(i => i > 300)) {
	console.log('COUCOU')
}
ready

Revisions

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