Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
iterate over map vs map entries vs map values vs array-backed map
(version: 1)
Comparing performance of:
map vs array-backed map vs map entries vs map values
Created:
6 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const map = new Map([[1,null],[2, null],[3, null],[4, null]]) const array = [1,2,3,4] const mapWithArray = new Map([[1,null],[2, null],[3, null],[4, null]]) function getStructures() { return { map, array, mapWithArray } }
Tests:
map
const {map, array, mapWithArray} = getStructures() for (const [key, value] of map) { key; value; }
array-backed map
const {map, array, mapWithArray} = getStructures() for (const key of array) { key; mapWithArray.get(key) }
map entries
const {map, array, mapWithArray} = getStructures() const entries = map.entries() for (const [key, value] of entries) { key; value; }
map values
const {map, array, mapWithArray} = getStructures() const values = map.values() for (const key of values) { key; mapWithArray.get(key) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
map
array-backed map
map entries
map values
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
map
79446616.0 Ops/sec
array-backed map
178940432.0 Ops/sec
map entries
81931488.0 Ops/sec
map values
137471920.0 Ops/sec
Related benchmarks:
For loop map vs map builtin for 10000000 elements
For loop map vs map builtin for 100000 elements
for vs map to fill array
MapOps
Array.apply vs .from vs map vs loop
Map values to Array: Array.from vs Array Spread
Map. foreach
Array.from vs map 1
iterate over map vs array-backed map
Comments
Confirm delete:
Do you really want to delete benchmark?