Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
public vs closure vs private
(version: 0)
Benchmark.js
Comparing performance of:
public vs closure vs private
Created:
3 years ago
by:
Guest
Go to the latest result
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();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
public
closure
private
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser/OS:
Firefox 122 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
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
Related benchmarks
ES6 property (get/set) & getter/setter function vs direct access to object attribute (private and not) v2
ES6 property (get/set) & getter/setter function vs direct access vs closure
"this" property vs. closure upvalue
Comments
Confirm delete:
Do you really want to delete benchmark?