HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
 
/*your preparation JavaScript code goes here
To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/
async function globalMeasureThatScriptPrepareFunction() {
    // This function is optional, feel free to remove it.
    // await someThing();
}
Tests:
  • Constructor parameters

    x
     
    class Component {
      constructor(x, y) {
        this.x = x;
        this.y = y;
      }
    }
    for(let i = 0; i < 100000; i++) {
      const component = new Component(i, i);
    }
  • Constructor object

     
    class Component {
      constructor(params) {
        const keys = Object.keys(params);
        for(let i = 0, l = keys.length; i < l; i++) {
          this[keys[i]] = params[i];
        }
      }
    }
    for(let i = 0; i < 100000; i++) {
      const component = new Component({ x: i, y: i});
    }
  • Factory function with object

     
    const createComponent = (params) => {
      const component = {};
      const keys = Object.keys(params);
      for(let i = 0, l = keys.length; i < l; i++) {
        component[keys[i]] = params[i];
      }
      return component;
    }
    for(let i = 0; i < 100000; i++) {
      const component = createComponent({ x: i, y: i});
    }
  • Factory function with definition and parameters

     
    const positionComponentDef = {
      x: Number,
      y: Number,
    };
    const createComponent= (def, ...params) => {
      const component = {};
      const keys = Object.keys(def);
      for(let i = 0, l = keys.length; i < l; i++) {
        component[keys[i]] = params[i];
      }
      return component;
    }
    for(let i = 0; i < 100000; i++) {
      const component = createComponent(positionComponentDef, i, i);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Constructor parameters
    Constructor object
    Factory function with object
    Factory function with definition and parameters

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0
Firefox 133 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Constructor parameters 167.4 Ops/sec
Constructor object 50.8 Ops/sec
Factory function with object 131.5 Ops/sec
Factory function with definition and parameters 149.1 Ops/sec