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
Go 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
fill twice
2K/s
from with mapper
43/s
View exact numbers
Test name
Executions per second
✓
fill twice
1,710 Ops/sec
from with mapper
43 Ops/sec
Related benchmarks
Array.from vs Array.fill
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?