Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.from vs map 1
(version: 1)
Comparing performance of:
Array.from vs Map vs Loop vs Loop push
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const LEN = 1e7;
Tests:
Array.from
Array.from({ length: LEN }, i => i)
Map
new Array(LEN).map(i => i);
Loop
const arr = new Array(LEN); for (let i = 0; i < LEN; i++) arr[i] = i
Loop push
const arr = [] for (let i = 0; i < LEN; i++) arr.push(i)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Array.from
Map
Loop
Loop push
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/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.from
3.3 Ops/sec
Map
22.3 Ops/sec
Loop
32.6 Ops/sec
Loop push
13.2 Ops/sec
Related benchmarks:
Array.from vs map
JS Loops tst
Create Array of length 10, where each element is an empty array
js array copy speed comparison v2
map.set vs array.push
best array generator
Array.from vs map vs Array.from then map
js array copy performance
Array.from vs map vs for vs push
Comments
Confirm delete:
Do you really want to delete benchmark?