comparing conversion of map values to array (v11)

Revision 11 of this benchmark created on


Setup

const yugeArray = Array.from(Array(10000).keys())

const myMap = new Map(yugeArray.map(i => [i, i]))


Test runner

Ready to run.

Testing in
TestOps/sec
getting array from map using array from
const myArray = Array.from(myMap.values())
ready
getting array from map using foreach
const myArray = []

myMap.forEach(item => myArray.push(item))
ready
getting array from map using forEach against map.values
const myArray = []

myMap.values().forEach(item => myArray.push(item))
ready
For loop
const myArray = []
for (const value of myMap.values()) {
  myArray.push(value)
}
ready
ye olde for loop
const myArray = []

for(let i = 0; i < myMap.size; i++) {
	myArray.push(myMap.get(i))
}
ready
spread
const myArray = [...myMap.values()]
ready

Revisions

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