Test name | Executions per second |
---|---|
Function approach | 4674214.0 Ops/sec |
Object approach | 4625951.0 Ops/sec |
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()
};
bench.fn(performance.now());
bench.cls.update(performance.now());