Script Preparation code:
x
 
function createFunctionBench() {
    let value = null;
    return function closure(val) {
        if (val) {
            value = val;
        }
        return value;
    };
}
class ClassBench {
    update(val) {
        if (val) {
            this.value = val;
        }
        return this.value;
    }
}
bench = {
    fn: createFunctionBench(),
    cls: new ClassBench()
};
Tests:
  • Function approach

     
    bench.fn(performance.now());
  • Object approach

     
    bench.cls.update(performance.now());
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Function approach
    Object approach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0
Firefox 117 on Ubuntu
View result in a separate tab
Test name Executions per second
Function approach 4674214.0 Ops/sec
Object approach 4625951.0 Ops/sec