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 out=7, v=5;
var f = function() {
return out+this.v;
};
var that = {
f: f,
v:5
};
var bound = f.bind(that);
var wrappedCall = function() {
f.call(that);
};
var slice = Array.prototype.slice;
Function.prototype.bind2 = function(_this) {
var _self = this;
var args = slice.call(arguments, 1);
if (args.length === 0) {
return function() {
if (arguments.length === 0) return _self.call(_this);
else if (arguments.length > 0) return _self.apply(_this, args);
}
}
return function() {
if (arguments.length === 0) return _self.apply(_this, args);
var a2 = args.contact(slice.call(arguments));
return _self.apply(_this, a2);
}
}
var bound2 = f.bind2(that);
var name = 'f';
//////////////
var emptyy = {};
Function.prototype.testUgly = function(that){
if (!that) that = emptyy
that.________ = this;
var length = arguments.length;
if (length === 1) var foo = that.________();
//else var foo = Function.prototype.call.apply(that.________, arguments);
delete that.________;
return foo;
}
//////////////
//ugly, won't work on async:
var emptyy = {};
var str = (function(){
if (!that) that = emptyy
that.________ = this;
var length = arguments.length;
if (length === 1) var foo = that.________();
////
else var foo = Function.prototype.call.apply(that.________, arguments);
delete that.________;
return foo;
}).toString();
str = str.slice(str.indexOf("{")+1, -1).split('////');
strend = str.pop()
for (var k=2, m=10; k<m; k++)
{
var tmp = '\t\telse if (length === '+k+') var foo = that.________('
var tmpA = []
for (var l=1; l<k; l++) tmpA.push('arguments['+l+']')
str.push(tmp + tmpA.join(',') + ');\n')
}
str.push(strend)
Function.prototype.uglyCall = new Function('that', str.join(' '))
//ugly:
var emptyy = {};
var str = (function(){
var id = performance.now()
this[id] = f;
var length = arguments.length;
if (length === 1) var foo = this[id]();
////
else
{ for (var k=0, m=length, args=[]; k<m; k++)
args.push(arguments[k])
var foo = f.apply(this, args);
}
delete this[id];
return foo;
}).toString();
str = str.slice(str.indexOf("{")+1, -1).split('////');
strend = str.pop()
for (var k=2, m=10; k<m; k++)
{
var tmp = '\t\telse if (length === '+k+') var foo = this.________('
var tmpA = []
for (var l=1; l<k; l++) tmpA.push('arguments['+l+']')
str.push(tmp + tmpA.join(',') + ');\n')
}
str.push(strend)
that.process = new Function('f', str.join(' '))
Ready to run.
Test | Ops/sec | |
---|---|---|
direct |
| ready |
apply |
| ready |
call |
| ready |
by string |
| ready |
direct (local) |
| ready |
ugly |
| ready |
ugly test |
| ready |
ugly process |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.