Tests:
  • Create object by function

    x
     
    const carFactory = (brand, seats) => ({
      brand,
      seats,
      sound: () => console.log("wrooom")
    })
    for(let i = 0; i < 20; i++) {
      carFactory(`brand-${i}`, 5)
    }
  • Create object by class

     
    class Car {
      brand;
      seats;
      
      constructor(brand, seats) {
        this.brand = brand;
        this.seats = seats;
      }
      
      sound() {
        return console.log("wrooom")
      }
    }
    for(let i = 0; i < 20; i++) {
      new Car(`brand-${i}`, 5)
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Create object by function
    Create object by class

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6.1 Safari/605.1.15
Safari 17 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Create object by function 9883335.0 Ops/sec
Create object by class 1731881.6 Ops/sec