Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flatMap vs reduce vs map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
reduce with concat
6063.2 Ops/sec
flatMap
3395.3 Ops/sec
map
3324.1 Ops/sec
Script Preparation code:
var arr = Array(100).fill({ portfolios: Array(100).fill(null) });
Tests:
reduce
arr.reduce((acc, x) => {acc.push(...x.portfolios); return acc;}, [])
flatMap
arr.flatMap(x => x.portfolios)
map
arr.map(x => x.portfolios).flat()
foreach
const result = []; arr.forEach(x => result.push(...x.portfolios));
for of
const result = []; for(const x of arr) result.push(...x.portfolios);