comparing foreach and array from

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

Revisions

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