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:
  • Class method

    x
     
    class TransformComponent {
      constructor(scaleX = 1.0, scaleY = 1.0, rotation = 0.0) {
        this.scaleX = scaleX;
        this.scaleY = scaleY;
        this.rotation = rotation;
      }
      
      scale(factor = 1.0) {
        this.scaleX *= factor;
        this.scaleY *= factor;
      }
    };
    for(let i = 0; i < 10000; i++) {
      const transform = new TransformComponent(i, i, i);
      transform.scale(2.0);
    }
  • Factory manager

     
    const components = new Map;
    const noop = () => {};
    const componentsMethodCaller = (factory, methodName, ...values) => {
      const methods = components.get(factory);
      return (methods[methodName] || noop).apply(null, values);
    }
    const transformFactory = (scaleX = 1.0, scaleY = 1.0, rotation = 0.0) => {
      return {
        scaleX,
        scaleY,
        rotation,
      };
    }
    components.set(transformFactory, {
      scale(component, factor = 1.0) {
        component.scaleX *= factor;
        component.scaleY *= factor;
      },
    });
    for(let i = 0; i < 10000; i++) {
      const transform = transformFactory(i, i, i);
      componentsMethodCaller(transformFactory, 'scale', 2.0);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Class method
    Factory manager

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15
Safari 15 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Class method 4393.5 Ops/sec
Factory manager 1118.0 Ops/sec