get/set on object vs on its prototype (v65)

Revision 65 of this benchmark created on


Description

Test specific access method to an object property.

Preparation HTML

<script>

  var obj = {
   _x: 0,
   _y: 0,
   get x() { return this._x; },
   set x(val) { this._x = val; }
  };
    

obj.prototype = {
 get y() { return this._y; },
 set y(val) { this._y = val; }
}

</script>

Setup

obj._x = 0;
    obj._y = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
get/set on object
acc = 0;
for (var i = 1000; i > 0; --i) {
  obj.x = i;
  acc += obj.x;
}
ready
get/set on prototype
acc = 0;
for (var i = 1000; i > 0; --i) {
  obj.y = i;
  acc += obj.y;
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.