Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
"this" property vs. closure upvalue
Is it more efficient to access upvalues or object properties?
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/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Return property class instance
10780022.0 Ops/sec
Return property of explicitly created object
10652499.0 Ops/sec
Return closure upvalue
10628931.0 Ops/sec
Script Preparation code:
const O1 = class { a = 1; get() { return this.a; } } var o1 = new O1(); const O2 = function() { return { a: 1, get: function() { return this.a; } } } var o2 = new O2(); const O3 = function() { let a = 1; return { get: function() { return a; } } } var o3 = new O3();
Tests:
Return property class instance
o1.get()
Return property of explicitly created object
o2.get()
Return closure upvalue
o3.get()