Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Reduce with spread operator vs without on a large array 2
Reduce with spread operator vs without on a large array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
reduce with spread
211.5 Ops/sec
reduce without spread
563.7 Ops/sec
Script Preparation code:
var array = new Array(10000).fill(1) function withSpread(item, index) { return { [`group${index}`]: { id: index, timestamp: new Date(new Date().getTime() + (index * 1000)), isOdd: index % 2 === 0, isEven: index % 2 !== 0 } } } function withOutSpread(acc, item, index) { acc[index] = { id: index, timestamp: new Date(new Date().getTime() + (index * 1000)), isOdd: index % 2 === 0, isEven: index % 2 !== 0 } return acc; }
Tests:
reduce with spread
Object.assign({}, ...array.map(withSpread))
reduce without spread
array.reduce(withOutSpread, {})