Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flatmap vs reduce for building arrays for objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Browser:
Chrome 149
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one month ago
flatMap
2K/s
reduce
1K/s
View exact numbers
Test name
Executions per second
✓
flatMap
1,705 Ops/sec
reduce
1,427 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var array = Array(10_000).fill({ id: 1 })
Tests:
flatMap
Object.fromEntries(array.flatMap((obj)=>[[obj.id,obj]]))
reduce
array.reduce((acc, obj)=>({...acc, [obj.id]: obj}),{})