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
Go 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
Loop
33/s
Map
22/s
Loop push
13/s
Array.from
3/s
View exact numbers
Test name
Executions per second
✓
Loop
33 Ops/sec
Map
22 Ops/sec
Loop push
13 Ops/sec
Array.from
3 Ops/sec
Related benchmarks
Array.from vs map
map.set vs array.push
Array.from vs map vs Array.from then map
Array.from vs map vs for vs push
Comments
Confirm delete:
Do you really want to delete benchmark?