Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
public vs closure vs private
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser:
Firefox 122
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
public
219691.1 Ops/sec
closure
139940.0 Ops/sec
private
220376.4 Ops/sec
Script Preparation code:
class PropertyAccess { _public = 0; #private = 0; constructor() { let closure = 0; this.closure_update = function() { closure++; }; } public_update(){ this._public++; } private_update(){ this.#private++; } } window.__measurethat_property_access = new PropertyAccess(); console.log(__measurethat_property_access);
Tests:
public
const pa = __measurethat_property_access; for (let x = 0; x < 1000; x++) pa.public_update();
closure
const pa = __measurethat_property_access; for (let x = 0; x < 1000; x++) pa.closure_update();
private
const pa = __measurethat_property_access; for (let x = 0; x < 1000; x++) pa.private_update();