Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
private/public class proprty access
(version: 1)
Comparing performance of:
private vs public
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
private
class MyClass { #_propertyOne = 1; #_propertyTwo = 2; #_sum = 0; sumProperties() { let sum = 0; for (let i = 0; i < 10_000; i++) sum += this.#_propertyOne + this.#_propertyTwo; } } new MyClass().sumProperties();
public
class MyClass { _propertyOne = 1; _propertyTwo = 2; sumProperties() { let sum = 0; for (let i = 0; i < 10_000; i++) sum += this._propertyOne + this._propertyTwo; } } new MyClass().sumProperties();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
private
public
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 138 on Android
View result in a separate tab
Embed
Embed Benchmark Result
public
5K/s
private
3K/s
View exact numbers
Test name
Executions per second
✓
public
5,115 Ops/sec
private
2,885 Ops/sec
Related benchmarks
className vs classList normalization
Splti vs Trim vs replace className
test early return
set vs uniq
set vs uniq2
classNames
classNames2
numeric vs string property accessor
byte double
Comments
Confirm delete:
Do you really want to delete benchmark?