Script Preparation code:
x
 
var array = new Array(10000).fill(1)
function withSpread(acc, item, index) {
    return {
        ...acc,
        [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

     
    array.reduce(withSpread, {})
  • reduce without spread

     
    array.reduce(withOutSpread, {})
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    reduce with spread
    reduce without spread

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
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
Chrome 122 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
reduce with spread 107.8 Ops/sec
reduce without spread 563.6 Ops/sec