Script Preparation code:
x
 
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)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Static object, static property
    Dynamic object, static property
    Dynamic object, const property
    Dynamic object, dynamic property

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Firefox 131 on Mac OS X 10.15
View result in a separate tab
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