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
<script>
function ClosureColor(name) {
// Have no choice but to add these methods to the instance
this.getName = function () {
return name;
};
this.setName = function (n) {
name = n;
};
}
function ClosureReturnColor(name) {
// Return object instead of attaching to Function
return {
getName: function () {
return name;
},
setName: function (n) {
name = n;
}
}
}
function PropertyColor(name) {
this._name = name;
this.getName = function () {
return this._name;
};
this.setName = function (n) {
this._name = n;
};
}
function PrototypeColor(name) {
this._name = name;
}
PrototypeColor.prototype.getName = function () {
return this._name;
};
PrototypeColor.prototype.setName = function (n) {
this._name = n;
};
function GetterSetterColor(name){
var value = name;
this.__defineGetter__("name", function(){
return value;
});
this.__defineSetter__("name", function(val){
value = val;
});
}
function ProtoGetterSetterColor(name){
this._name = name;
}
ProtoGetterSetterColor.prototype = {
get name() {
return this._name;
},
set name(name) {
return this._name = name;
}
}
function ObjectColor(name) {
return {_name: name};
}
ObjectColor.getName = function(object) {
return object._name;
}
ObjectColor.setName = function(object, name) {
object._name = name;
}
function ObjectColor2(name) {
this._name = name;
}
ObjectColor2.getName = function(object) {
return object._name;
}
ObjectColor2.setName = function(object, name) {
object._name = name;
}
function ObjectColor3(name) {
this._name = name;
}
function ObjectColor3_getName(object) {
return object._name;
}
function ObjectColor3_setName(object, name) {
object._name = name;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Closure |
| ready |
Property |
| ready |
Prototype |
| ready |
Closure Return |
| ready |
Getter Setter |
| ready |
Prototype Getter Setter |
| ready |
Object |
| ready |
Object2 |
| ready |
Object3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.