Test name | Executions per second |
---|---|
Read from data property | 12674681.0 Ops/sec |
Write to data property | 12658246.0 Ops/sec |
Read from accessor method | 12462773.0 Ops/sec |
Write to mutator method | 3327352.0 Ops/sec |
Read from object literal property | 10042829.0 Ops/sec |
Write to object literal property | 2179403.0 Ops/sec |
Read from object literal property on prototype | 12109050.0 Ops/sec |
Write to object literal property on prototype | 2811944.2 Ops/sec |
const foo = 5
var data = {
property: foo
};
var method = {
getProperty: function() {
return foo;
},
setProperty: function(value) {
property = value;
}
};
var objectLiteralAccessor = {
get property() {
return foo;
},
set property(value) {
property = value;
}
};
function Class() {
}
Class.prototype = {
get property() {
return foo;
},
set property(value) {
property = value;
}
};
var prototypeAccessor = new Class();
var value = data.property;
data.property = true;
var value = method.getProperty();
method.setProperty(true);
var value = objectLiteralAccessor.property;
objectLiteralAccessor.property = true;
var value = prototypeAccessor.property;
prototypeAccessor.property = true;