Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
public vs closure vs private
(version: 0)
Comparing performance of:
public vs closure vs private
Created:
3 years ago
by:
Guest
Jump 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
Test name
Executions per second
public
219691.1 Ops/sec
closure
139940.0 Ops/sec
private
220376.4 Ops/sec
Related benchmarks:
lookup vs closure declaration
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?