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
superUseCaller = (function() {
var callSuper = function(){
var caller = callSuper.caller
return caller._super.apply(this, arguments);
}
function Parent () {
this.i=0;
}
Parent.prototype.methodA = function() {
this.i++
}
function Child() {
this.i=0;
}
Child.prototype = new Parent();
Child.prototype._super = callSuper;
Child.prototype.methodA = function() {
this.i++;
this._super();
}
Child.prototype.methodA._super = Parent.prototype.methodA;
return {
Parent: Parent,
Child: Child
}
})();
superUseInject = (function() {
"use strict"
function emptyFn() {}
function isFunction(obj) {
return Object.prototype.toString.call(obj) === "[object Function]";
}
var injectSuper = function(ancestor, name, fn){
function _injected() {
this._super = ancestor[name];
// fail-over incase ancestor has no such method
if (!isFunction(this._super)) {
this._super = emptyFn;
}
return fn.apply(this, arguments);
}
return _injected;
}
function Parent () {
this.i=0;
}
Parent.prototype.methodA = function() {
this.i++;
}
function Child() {
this.i=0;
}
Child.prototype = new Parent();
Child.prototype.methodA = function() {
this.i++;
this._super();
}
Child.prototype["methodA"] = injectSuper(Parent, "methodA", Child.prototype.methodA);
return {
Parent: Parent,
Child: Child
}
})();
Ready to run.
Test | Ops/sec | |
---|---|---|
Use Caller |
| ready |
Use Inject |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.