Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
reduce spread push vs flatmap
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/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
flatMap
304.6 Ops/sec
reduce spread push
303.0 Ops/sec
reduce append
303.8 Ops/sec
Script Preparation code:
var arr = Array(10_000).fill(0) function getErrors() { const num = Math.floor(Math.random() * 4); return Array(num).fill("string"); }
Tests:
flatMap
arr.flatMap(x => getErrors())
reduce spread push
arr.reduce((errors, x) => { errors.push(...getErrors()); return errors; }, [])
reduce append
arr.reduce((errors, x) => { errors.concat(getErrors()); return errors; }, [])