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>
Object.defineProperties(Object.prototype, {
_create: {
value: function(state) {
var This = this.constructor;
if (This.prototype !== this && this.hasOwnProperty('constructor')) This.prototype = this;
return new This(state);
},
writable: true,
configurable: true
},
_create2: {
value: function(state) {
var obj = state;
obj.__proto__ = this;
return obj;
},
writable: true,
configurable: true
},
constructor: {
value: function(state) {
for (var name in state) this[name] = state[name]
},
writable: true,
configurable: true
}
});
object$ = Object.prototype;
Object.create2 = function(proto){
var obj = {};
obj.__proto__ = proto;
return obj;
}
Object.create3 = (function() {
var Object = function() {};
return function (prototype) {
if (arguments.length > 1) {
throw new Error('Second argument not supported');
}
if (typeof prototype != 'object') {
throw new TypeError('Argument must be an object');
}
Object.prototype = prototype;
var result = new Object();
Object.prototype = null;
return result;
};
})();
var objF = function (prop){return Object.create(prop);}
</script>
function Actual (){}
function MyClass(x, y) {
//this.x = x;
//this.y = y;
Actual.prototype = {x:x,y:y};
return new Actual();
}
var MyProtoClass = {
init: (function(x, y) {
this.x = x;
this.y = y;
return this;
}),
x: 0,
y: 0
};
function doSomething(obj) {
var x = obj.x + obj.y,
y = obj.x * obj.y,
z = obj.x - obj.y;
return x * y * z;
}
var x = 0 | (Math.random() * 10000),
y = 0 | (Math.random() * 10000);
var OBJ = {x: x, y :0};
Ready to run.
Test | Ops/sec | |
---|---|---|
Object.create |
| ready |
new operator |
| ready |
Object.create().init() |
| ready |
Object.create() |
| ready |
prototype._create() |
| ready |
prototype._create2() by __proto__ |
| ready |
Object.create2 by __proto__ |
| ready |
Object.create3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.