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
var inherit = function() {
'use strict';
var o = 'object',
p = 'prototype',
c = 'constructor',
newfunction = function(){},
args = arguments,
parent = args[0],
bodyclass = (args.length == 1) ? newfunction : args[1],
parentisobject = typeof parent === o,
body,
newproto,
hasconstructor;
if (typeof bodyclass === o) {
body = newfunction;
body[p] = bodyclass;
}
else {
body = bodyclass;
body[p] = (parentisobject) ? parent : new parent();
}
newproto = new body(body[p]);
hasconstructor = !newproto.hasOwnProperty(c);
if ( (hasconstructor && parent === newproto[c]) || (hasconstructor && parentisobject) )
newproto[c] = newfunction;
newproto[c][p] = newproto;
return newproto[c];
};
var inherit2 = function() {
'use strict';
var o = 'object',
p = 'prototype',
c = 'constructor',
parent = arguments[0],
bodyclass = (arguments.length == 1) ? function(){} : arguments[1],
parentisobject = typeof parent === o,
body,
newproto,
hasconstructor;
if (typeof bodyclass === o) {
body = function(){};
body.prototype = bodyclass;
}
else {
body = bodyclass;
body.prototype = (parentisobject) ? parent : new parent();
}
newproto = new body(body.prototype);
if ( (!newproto.hasOwnProperty(c) && parent === newproto.constructor) || (!newproto.hasOwnProperty(c) && parentisobject) )
newproto.constructor = function(){};
newproto.constructor.prototype = newproto;
return newproto.constructor;
};
var inherit3 = function() {
'use strict';
var o = 'object',
p = 'prototype',
c = 'constructor',
newfunction = new Function,
args = arguments,
parent = args[0],
bodyclass = (args.length == 1) ? newfunction : args[1],
parentisobject = typeof parent === o,
body,
newproto,
hasconstructor;
if (typeof bodyclass === o) {
body = newfunction;
body[p] = bodyclass;
}
else {
body = bodyclass;
body[p] = (parentisobject) ? parent : new parent();
}
newproto = new body(body[p]);
hasconstructor = !newproto.hasOwnProperty(c);
if ( (hasconstructor && parent === newproto[c]) || (hasconstructor && parentisobject) )
newproto[c] = newfunction;
newproto[c][p] = newproto;
return newproto[c];
};
var inherit22 = function() {
'use strict';
function newfunction(){}
var o = 'object',
p = 'prototype',
c = 'constructor',
args = arguments,
parent = ( args.length > 1 ) ? args[0] : newfunction,
body = args[ args.length-1 ],
new_proto;
body[p] = Object.create( parent[p] ),
new_proto = new body( body[p] );
if ( !new_proto.hasOwnProperty(c) && parent === new_proto[c] )
new_proto[c] = newfunction;
new_proto[c][p] = new_proto;
return new_proto[c];
};
var inherit1 = function() {
'use strict';
var len = arguments.length,
parent = (len > 1) ? arguments[0] : function(){},
body = arguments[len - 1];
body.prototype = Object.create(parent.prototype);
var prototype = new body(body.prototype);
prototype.constructor.prototype = prototype;
return prototype.constructor;
};
var inheriten = (function() {
'use strict';
var o = 'object',
p = 'prototype',
c = 'constructor',
args,
parent,
bodyclass,
newfunction,
parentisobject,
body,
newproto,
hasconstructor;
return function() {
newfunction = function(){},
args = arguments,
parent = args[0],
bodyclass = (args.length == 1) ? newfunction : args[1],
parentisobject = typeof parent === o;
if (typeof bodyclass === o) {
body = newfunction;
body[p] = bodyclass;
}
else {
body = bodyclass;
body[p] = (parentisobject) ? parent : new parent();
}
newproto = new body( body[p] );
hasconstructor = !newproto.hasOwnProperty(c);
if ( (hasconstructor && parent === newproto[c]) || (hasconstructor && parentisobject) )
newproto[c] = newfunction;
newproto[c][p] = newproto;
return newproto[c];
}
})();
Ready to run.
Test | Ops/sec | |
---|---|---|
released |
| ready |
no alias |
| ready |
new Function |
| ready |
inherit 1.0 (lite) |
| ready |
encapsuled |
| ready |
v2.2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.