Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map vs obj creating and accessing
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Using the spread operator
42.2 Ops/sec
Using Object.assign
96.6 Ops/sec
Accessing map
0.7 Ops/sec
Accessing object
0.7 Ops/sec
Script Preparation code:
const data = new Array(1000000) .fill(1) .map((item) => Math.floor(Math.random() * 10000)) const map1 = new Map(); const map2 = {}
Tests:
Using the spread operator
data.forEach((item) => { map1.set(item, Math.random()); });
Using Object.assign
data.forEach((item) => { map2[item] = Math.random(); });
Accessing map
data.forEach((item) => { console.log(map1.get(item)); });
Accessing object
data.forEach((item) => { console.log(map2[item]); });