Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Wrapped 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; rv:125.0) Gecko/20100101 Firefox/125.0
Browser:
Firefox 125
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Static object, static property
29953.8 Ops/sec
Dynamic object, static property
17791.4 Ops/sec
Dynamic object, const property
1887.9 Ops/sec
Dynamic object, dynamic property
2004.9 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 wrappedValue1(x) { return getValue1(x); } function getValue2(x, anyHolder=holder) { return anyHolder.value; } function wrappedValue2(x) { return getValue2(x); } function getValue3(x, anyHolder=holder) { const propName = "value"; return anyHolder[propName]; } function wrappedValue3(x) { return getValue3(x); } function getValue4(x, anyHolder=holder, propName="value") { return anyHolder[propName]; } function wrappedValue4(x) { return getValue1(4); } function benchmark(func) { let x; for (let i = 0; i < 1000000; i++) { x = func(i); } return x; }
Tests:
Static object, static property
benchmark(wrappedValue1)
Dynamic object, static property
benchmark(wrappedValue2)
Dynamic object, const property
benchmark(wrappedValue3)
Dynamic object, dynamic property
benchmark(wrappedValue4)