Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map vs obj xzdd
(version: 1)
bench
Comparing performance of:
Using the spread operator vs Using Object.assign
Created:
6 months ago
by:
Guest
Go to the latest result
Script Preparation code:
const data = new Array(1000000) .fill(1) .map((item) => Math.floor(Math.random() * 10000))
Tests:
Using the spread operator
const map = new Map(); data.forEach((item) => { map.set(item, Math.random()); });
Using Object.assign
const map = {} data.forEach((item) => { map[item] = Math.random(); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Using the spread operator
Using Object.assign
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
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/OS:
Chrome 144 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Using Object.assign
110/s
Using the spread operator
46/s
View exact numbers
Test name
Executions per second
✓
Using Object.assign
110 Ops/sec
Using the spread operator
46 Ops/sec
Related benchmarks
map vs object - key access 2
map vs object - key access 4
map vs object - key access (string key)
map vs obj creating and accessing
map vs obj creating and accessing 2
Comments
Confirm delete:
Do you really want to delete benchmark?