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:
3 months ago
by:
Guest
Jump 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:
3 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
Test name
Executions per second
Using the spread operator
46.4 Ops/sec
Using Object.assign
110.1 Ops/sec
Related benchmarks:
Large Map vs Object 2
map vs object - key access
map vs object - key access 2
map vs object - key access 4
set + array.from + map vs map + set
map vs object - key access (string key)
map vs object - key access (string key2)
map vs obj creating and accessing
map vs obj creating and accessing 2
Comments
Confirm delete:
Do you really want to delete benchmark?