Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS: Getter/Setter vs Direct Access Performance
(version: 1)
Comparing performance of:
access existing value vs access default value vs access static value
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const existingA = 'truthy-value'; const existingB = undefined; class Env { get a() { return existingA || 'a-default-value'; } get b() { return existingB || 'b-default-value'; } } const env = new Env(); const config = { c: 'c-value', };
Tests:
access existing value
function a() { return env.a; } const aReading = a();
access default value
function b() { return env.b; } const bReading = b();
access static value
function c() { return config.c; } const cReading = c();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
access existing value
access default value
access static value
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
access existing value
278953312.0 Ops/sec
access default value
136031408.0 Ops/sec
access static value
279294240.0 Ops/sec
Related benchmarks:
globals vs. upvalues
assigning undefined vs null
isIteratorOrAsyncIterator
Object defineProperty on class
=1vman
if condition speed test 3
Test JS getter/setter
Object.assign vs normal set
call vs if
Comments
Confirm delete:
Do you really want to delete benchmark?