Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
private
220K/s
public
220K/s
closure
140K/s
View exact numbers
Test name
Executions per second
✓
private
220,376 Ops/sec
public
219,691 Ops/sec
closure
139,940 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();