comparing conversion of map values to array (v10)

Revision 10 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

Revisions

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