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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Direct get
14953725.0 Ops/sec
proxied get
14913985.0 Ops/sec
direct set
193386928.0 Ops/sec
proxied set
206474560.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;