Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Dict vs. Map vs. Array (all entries)
(version: 1)
Large dictionary - how worse is it from array with direct reference? And how does Map perform?
Comparing performance of:
Dictionary vs Array vs Map
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var dict= {} for (var i=0; i<50000; i++) { dict['abc_'+i] = i; } var map= new Map() for (var i=0; i<50000; i++) { map.set('abc_'+i, i); } var arr = [] for (var i=0; i<50000; i++) { arr.push(i); }
Tests:
Dictionary
let c = 0 for (i=0; i<10000; i+=1) { c += dict['abc_'+i]}
Array
let c = 0 for (i=0; i<10000; i+=1) { c += arr[i]}
Map
let c = 0 for (i=0; i<10000; i+=1) { c += map.get('abc_'+i)}
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Dictionary
Array
Map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Dictionary
1740.5 Ops/sec
Array
5136.0 Ops/sec
Map
1452.2 Ops/sec
Related benchmarks:
Array constructor vs literal
Array constructor vs literal performance - 1000 items
Dict vs. Map vs. Array
Map vs Object - the real test
Dict vs. Map vs. Array ( complete iteration)
Dict vs. Map vs. Array ( complete iteration 2)
Dict vs. Map vs. Array ( complete iteration 3)
Dict vs. Map vs. Array ( complete iteration Ultimate Collection)
Dict vs. Map vs. Array ( complete iteration 4)
Comments
Confirm delete:
Do you really want to delete benchmark?