Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Public vs Private properties
Comparing the get and set performance of directly accessing a field on a class versus using a getter/setter pair on a private property.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Direct get
1354359296.0 Ops/sec
proxied get
1363131136.0 Ops/sec
direct set
1900957184.0 Ops/sec
proxied set
1849694720.0 Ops/sec
Script Preparation code:
class Test { get bar() { return this.#bar }; set bar(v) { this.#bar = v }; foo = 1; #bar = 1; } var test = new Test; var x;
Tests:
Direct get
x = test.foo;
proxied get
x = test.bar
direct set
test.foo = 2;
proxied set
test.bar = 2;