Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Class field access speed v1
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Static object, static property
18682.2 Ops/sec
Dynamic object, static property
1815.8 Ops/sec
Dynamic object, const property
1829.2 Ops/sec
Dynamic object, dynamic property
1726.0 Ops/sec
Script Preparation code:
class ValueHolder { #value; get value() {return this.#value;} set value(v) {this.#value = v;} } const holder = new ValueHolder(); function getValue1(x) { return holder.value; } function getValue2(x, anyHolder=holder) { return anyHolder.value; } function getValue3(x, anyHolder=holder) { const propName = "value"; return anyHolder[propName]; } function getValue4(x, anyHolder=holder, propName="value") { return anyHolder[propName]; } function benchmark(func) { let x; for (let i = 0; i < 1000000; i++) { x = func(i); } return x; }
Tests:
Static object, static property
benchmark(getValue1)
Dynamic object, static property
benchmark(getValue2)
Dynamic object, const property
benchmark(getValue3)
Dynamic object, dynamic property
benchmark(getValue4)