Tests:
  • object update with spread operator

    AخA
     
    let obj = {}
    for (let i = 0; i < 1000; i++) {
      obj = {...obj, [i]: (i || 0) + 1}
    }
  • object update with indexing

     
    const obj = {}
    for (let i = 0; i < 1000; i++) {
      obj[i] = (obj[i] || 0) + 1
    }
  • map update

     
    const map = new Map()
    for (let i = 0; i < 1000; i++) {
      map.set(i, (map.get(i) || 0) + 1)
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    object update with spread operator
    object update with indexing
    map update

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.97 Safari/537.36
Chrome 96 on Linux
View result in a separate tab
Test name Executions per second
object update with spread operator 2739.1 Ops/sec
object update with indexing 53870.3 Ops/sec
map update 24568.5 Ops/sec