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; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
reduce
6874.4 Ops/sec
flatMap
5508.5 Ops/sec
map
5301.4 Ops/sec
foreach
6760.9 Ops/sec
for of
6903.6 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);