Tests:
  • Create object by function

    x
     
    const carFactory = (brand, seats) => ({
      brand, seats
    })
    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;
      }
    }
    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 years ago)
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0
Firefox 112 on Linux
View result in a separate tab
Test name Executions per second
Create object by function 83041816.0 Ops/sec
Create object by class 274366.3 Ops/sec