Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flatMap vs reduce with spread vs reduce with push vs for of vs push ...
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.5.1
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
reduce with spread
10.3 Ops/sec
flatMap
14381.9 Ops/sec
reduce with push
32713.8 Ops/sec
for...of
33380.9 Ops/sec
push(...arr)
19727.3 Ops/sec
Script Preparation code:
var arr = Array(10_000).fill(0)
Tests:
reduce with spread
arr.reduce((acc, x) => [...acc, x], [])
flatMap
arr.flatMap(x => [x])
reduce with push
arr.reduce((acc, x) => { acc.push(x); return acc; }, [])
for...of
const acc = [] for (const x of arr) { acc.push(x); }
push(...arr)
const acc = [] acc.push(...arr);