Test case details

Preparation Code

<script>   obj = {    _x: 0   }     var acc = 0;     funct = {    get: function() {     return this._x    },    set: function(value) {     this._x = value    }   } </script>

Test cases

Test #1

Object.defineProperty(obj, "x", {  get: funct['get'],  set: funct['set'] }) for (var i = 0; i < 1000; i++) {  obj.x = i;  acc += obj.x; }

Test #2

obj.__defineGetter__('x', funct['get']); obj.__defineSetter__('x', funct['set']); for (var i = 0; i < 1000; i++) {  obj.x = i;  acc += obj.x; }

Test #3

for (var i = 0; i < 1000; i++) {  obj._x = i;  acc += obj._x; }

Test #4

obj.prototype = {  get x() {   return this._x;  }, set x(value) {   this_x = value;  } } for (var i = 0; i < 1000; i++) {  obj.x = i;  acc += obj.x; }

Test #5

obj.setX = function(value) {  this._x = value; } for (var i = 0; i < 1000; i++) {  obj.setX(i);  acc += obj._x; }

Test #6

Object.defineProperty(obj, "x", {  value: 0,  writable: false,  configurable: false }) for (var i = 0; i < 1000; i++) {  obj.x = i;  acc += obj.x; }