Tests:
  • boring

    AخA
     
    const obj = {
      hello: "world"
    };
    if (Math.random()>.5) {
      obj.foo = "bar";
    }
  • spread

     
    const obj = {
      hello: "world",
      ...Math.random()>.5 && { foo: "bar" }
    };
  • Object.assign

     
    const obj = Object.assign({
      hello: "world"
    }, Math.random()>.5 && {
      foo: "bar"
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    boring
    spread
    Object.assign

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Android 11; Mobile; rv:88.0) Gecko/88.0 Firefox/88.0
Firefox Mobile 88 on Android
View result in a separate tab
Test name Executions per second
boring 34740276.0 Ops/sec
spread 6666045.0 Ops/sec
Object.assign 8506570.0 Ops/sec