Performance filter vs if

Benchmark created on


Description

test performance filter vs for and if

Setup

var testData = []
for (var i = 0; i < 100; i++) {
  testData.push(i)
}

Test runner

Ready to run.

Testing in
TestOps/sec
filter
testData.filter(i => i > 50).forEach(i => i * 2)
ready
if
testData.forEach(i => {
	if (i > 50) {
		i => i * 2
	}
})
ready

Revisions

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