Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
flatMap vs reduce-push vs flat
Compare flatMap performance vs Array.reduce with Array.push
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
reduce with push
34/s
flatMap
23/s
flat
19/s
View exact numbers
Test name
Executions per second
✓
reduce with push
34 Ops/sec
flatMap
23 Ops/sec
flat
19 Ops/sec
Script Preparation code:
var data = []; for (let i = 0; i < 100000; i++) { data[i] = Array(10).fill(0); }
Tests:
reduce with push
data.reduce((acc, x) => { acc.push(...x); return acc; }, []);
flatMap
data.flatMap(x => x);
flat
data.flat(Infinity);