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
Go 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:
one year 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
Map first then Array.from
17/s
Spread first then map
10/s
View exact numbers
Test name
Executions per second
✓
Map first then Array.from
17 Ops/sec
Spread first then map
10 Ops/sec
Related benchmarks
Array.from vs Array.fill
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?