Script Preparation code:
x
 
var state = {}
var cols = [{id: 1, key: 'value'}, {id: 2, key: 'value'}]
for (var i = 0; i < 2000; i++) {
    state[i] = {
        id: i,
        key: 'value'
    };
};
Tests:
  • Spread

     
    const colDefs = cols.map(c => {return {[c.id]: c}});
    const test = Object.assign({}, state, ...colDefs);
  • Mutate

     
    const colDefs = {}
    cols.forEach(c => {
      colDefs[c.id] = c;
    });
    const test = Object.assign({}, state, colDefs);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Spread
    Mutate

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0
Firefox 77 on Ubuntu
View result in a separate tab
Test name Executions per second
Spread 3121.3 Ops/sec
Mutate 3181.2 Ops/sec