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 bindImpl = Function.prototype.bind ||
function(oThis) {
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() { },
fBound = function() {
return fToBind.apply(this instanceof fNOP && oThis ?
this :
oThis,
aArgs.concat(Array.prototype.slice.call(arguments))
);
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
var native = function() {
this.label = "hello";
this.stringAppend = function() {
return this.label + "world";
}
};
var nativeInstance = new native();
var proto = function() {
this.label = "hello";
};
proto.prototype.stringAppend = function() {
return this.label + "world";
};
var protoInstance = new proto();
var bindStringAppend = function() {
return this.label + "world";
};
var thisObj = function() {
this.label = "hello";
this.stringAppend = bindImpl.call(bindStringAppend, this);
};
var boundImpl = new thisObj();
var closure = function() {
this.label = "hello";
var self = this;
this.stringAppend = function() {
return self.label + "world";
};
};
var closureInstance = new closure();
// test function and context
var nativeImpl = nativeInstance.stringAppend;
var protoImpl = protoInstance.stringAppend;
var closureImpl = closureInstance.stringAppend;
var boundImpl = boundImpl.stringAppend;
Ready to run.
Test | Ops/sec | |
---|---|---|
Native |
| ready |
Proto |
| ready |
Closure |
| ready |
Bind |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.