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>
var A, B, C, b, c;
function inheritPrototype(Parent, extend) {
function F() {};
function Child() {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.prototype.superclass = Parent.prototype;
Object.keys(extend).forEach(function (key) {
Child.prototype[key] = extend[key];
});
return Child;
};
function inheritBase(Parent, extend) {
function Child() {};
Object.keys(extend).forEach(function (key) {
var baseMethod = Parent.prototype[key];
Child.prototype[key] = function () {
var baseSaved = this.__base,
result;
this.__base = baseMethod;
result = extend[key].apply(this, arguments);
this.__base = baseSaved;
return result;
}
});
return Child;
}
A = function () {};
A.prototype = {
getRandom: function () {
return 4;
}
}
B = inheritPrototype(A, {
getRandom: function () {
return this.superclass.getRandom();
}
});
C = inheritBase(A, {
getRandom: function () {
return this.__base();
}
})
b = new B();
c = new C();
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
superclass |
| ready |
__base |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.