Script Preparation code:
x
 
var property = 0;
var data = {
  property: property
};
var method = {
  getProperty: function() {
    return property;
  },
  setProperty: function(value) {
    property = value;
  }
};
var objectLiteralAccessor = {
  get property() {
    return property;
  },
  set property(value) {
    property = value;
  }
};
function Class() {
}
Class.prototype = {
  get property() {
    return property;
  },
  set property(value) {
    property = value;
  }
};
    
var prototypeAccessor = new Class();
var p0 = new Proxy({}, {
   get(target, prop, receiver) {
    return property;
  },
  set(target, prop, value) {
    property = value;
    return true;
  },
});
var p1 = new Proxy({ property: 0 }, {
   get(target, prop, receiver) {
    return target[prop]
  },
  set(target, prop, value) {
    target[prop] = value;
    return true;
  },
});
var p2 = new Proxy({ property: 0 }, {
   get(target, prop, receiver) {
    return Reflect.get(target, prop, receiver);
  },
  set(target, prop, value, receiver) {
    return Reflect.set(target, prop, value, receiver);
  },
});
Tests:
  • Read from data property

     
    var value = data.property;
  • Write to data property

     
    data.property = property+1;
  • Read from accessor method

     
    var value = method.getProperty();
  • Write to mutator method

     
    method.setProperty(property+1);
  • Read from object literal property

     
    var value = objectLiteralAccessor.property;
  • Write to object literal property

     
    objectLiteralAccessor.property = property+1;
  • Read from object literal property on prototype

     
    var value = prototypeAccessor.property;
  • Write to object literal property on prototype

     
    prototypeAccessor.property = property+1;
  • R p0

     
    var value = p0.property;
  • W p0

     
    p0.property = property+1;
  • r p1

     
    var value = p1.property;
  • w p1

     
    p1.property = property+1;
  • r p2

     
    var value = p2.property;
  • w p2

     
    p2.property = property+1;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Read from data property
    Write to data property
    Read from accessor method
    Write to mutator method
    Read from object literal property
    Write to object literal property
    Read from object literal property on prototype
    Write to object literal property on prototype
    R p0
    W p0
    r p1
    w p1
    r p2
    w p2

    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/118.0.0.0 Safari/537.36
Chrome 118 on Windows
View result in a separate tab
Test name Executions per second
Read from data property 25551044.0 Ops/sec
Write to data property 12813608.0 Ops/sec
Read from accessor method 12791210.0 Ops/sec
Write to mutator method 7580195.5 Ops/sec
Read from object literal property 11415879.0 Ops/sec
Write to object literal property 5507650.0 Ops/sec
Read from object literal property on prototype 12877096.0 Ops/sec
Write to object literal property on prototype 7573325.5 Ops/sec
R p0 10788188.0 Ops/sec
W p0 6737351.0 Ops/sec
r p1 18332918.0 Ops/sec
w p1 10410502.0 Ops/sec
r p2 7762643.5 Ops/sec
w p2 2903119.0 Ops/sec