Array.map vs equivalent function calls

Benchmark created on


Description

This tests the difference between a function called once that returns a mapped array vs a function that is called the equivalent number of times individually

Setup

function goMap(numbers = []) {
	return numbers.map(i => i)
}

function goReturnNumber(number) {
	return number
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.Map()
goMap([1, 2, 3, 4, 5, 6])
ready
Return number
goReturnNumber(1)
goReturnNumber(2)
goReturnNumber(3)
goReturnNumber(4)
goReturnNumber(5)
goReturnNumber(6)
ready

Revisions

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