Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Spread first vs map first then Array.from
(version: 1)
Comparing performance of:
Spread first then map vs Map first then Array.from
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let foo = new Map(); for (let i = 0; i < 1_000_000; i++) { foo.set(i, i % 8); }
Tests:
Spread first then map
[...foo.entries()].map(([i, iMod8]) => [i, iMod8.toString()])
Map first then Array.from
Array.from(foo.entries().map(([i, iMod8]) => [i, iMod8.toString()]))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Spread first then map
Map first then Array.from
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Spread first then map
9.6 Ops/sec
Map first then Array.from
17.3 Ops/sec
Related benchmarks:
map vs obj2
Array.from vs Array.fill
Object spread vs New map entries
Array.from vs Spread. Map 1000000
Iterating map v2
gfhg hgfh hgfdhgf gfdh hfdghgh
array.from vs spread on Map
map vs object test here
Array.from vs Array.fill vs [...Array].map
Comments
Confirm delete:
Do you really want to delete benchmark?