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 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)
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: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123 on Windows
View result in a separate tab
Test name Executions per second
Static object, static property 23.5 Ops/sec
Dynamic object, static property 21.3 Ops/sec
Dynamic object, const property 21.5 Ops/sec
Dynamic object, dynamic property 21.2 Ops/sec