Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map vs obj filling and accessing (string as key)
(version: 1)
Comparing performance of:
Filling map vs Filling object vs Accessing map vs Accessing object
Created:
3 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
const data = new Array(1000000) .fill(1) .map((item) => "somekeeeey-" + String(Math.floor(Math.random() * 10000))) const map1 = new Map(); const map2 = {}
Tests:
Filling map
data.forEach((item) => { map1.set(item, { id: item, rand: Math.random() }); });
Filling object
data.forEach((item) => { map2[item] = { id: item, rand: Math.random() }; });
Accessing map
const aggr = [] data.forEach((item) => { aggr.push(map1.get(item)) });
Accessing object
const aggr = [] data.forEach((item) => { aggr.push(map2[item]); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Filling map
Filling object
Accessing map
Accessing object
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser/OS:
Chrome 145 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Filling map
32.0 Ops/sec
Filling object
45.6 Ops/sec
Accessing map
35.7 Ops/sec
Accessing object
19.4 Ops/sec
Related benchmarks:
map vs object - key access
map vs object - key access 2
map vs object - key access 4
map vs object - key access (string key)
map vs object - key access (string key2)
map vs obj xzdd
map vs obj creating and accessing
map vs obj creating and accessing 2
map vs obj filling and accessing
Comments
Confirm delete:
Do you really want to delete benchmark?