jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Test different access method to an object property
function getter() { return this._x; }
function setter(value) { this._x = value; }
var acc = 0;
var standardObj = { x: 0 }
var definePropertyObj = { _x: 0 }
var getterSetterObj = { _x: 0 }
var getterSetterFnObj = { _x: 0 }
var prototypeObj = { _x: 0 }
var definePropertyObjPrototype = {};
Object.defineProperty(definePropertyObjPrototype, "x_proto1", {
get: getter,
set: setter
});
definePropertyObj.prototype = definePropertyObjPrototype ;
Object.defineProperty(definePropertyObj, "x", {
get: getter,
set: setter
});
var getterSetterObjPrototype = {}
getterSetterObjPrototype .__defineGetter__("x_proto2", getter);
getterSetterObjPrototype .__defineSetter__("x_proto2", setter);
getterSetterObj.prototype = getterSetterObjPrototype;
getterSetterObj.__defineGetter__("x", getter);
getterSetterObj.__defineSetter__("x", setter);
getterSetterFnObj.getX = getter;
getterSetterFnObj.setX = setter;
prototypeObj.prototype = {
get x_proto3() { return this._x; },
set x_proto3(value) { this._x = value; }
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Object.defineProperty on prototype |
| ready |
__defineGetter__ on instance |
| ready |
Normal |
| ready |
Prototype |
| ready |
Setter |
| ready |
Object.defineProperty on instance |
| ready |
__defineGetter__ on prototype |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.