Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.from with mapper vs Array.fill
(version: 1)
Comparing performance of:
from with mapper vs fill twice
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
from with mapper
let n = 10000, length = 50 const result = [] const lengthObj = {length:length} const mapper = (_, i) => i < 25 ? 0 : 1 for (let i = 0; i < n; ++i) { result.push(Array.from(lengthObj, mapper)); }
fill twice
let n = 10000, length = 50 const result = [] for (let i = 0; i < n; ++i) { result.push(Array(5).fill(0, 0, 25).fill(1, 25)); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
from with mapper
fill twice
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 132 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
from with mapper
42.8 Ops/sec
fill twice
1709.9 Ops/sec
Related benchmarks:
For loop map vs map builtin for 10000000 elements
for vs foreach vs map 2
Array.from vs Array.fill
Create New Array & Fill it
Array fill method vs for loop vs map
Array.from vs map vs Array.from then map
Array.from vs map vs for vs push
Array.from vs Array.fill (zeroes)
Array.from vs map 1
Comments
Confirm delete:
Do you really want to delete benchmark?