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 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Browser:
Firefox 131
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Static object, static property
3194.0 Ops/sec
Dynamic object, static property
343.3 Ops/sec
Dynamic object, const property
343.5 Ops/sec
Dynamic object, dynamic property
317.2 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)