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 slice = Array.prototype.slice,
push = Array.prototype.push;
Function.prototype.bindFirst = function(context){
var fn = this, args = slice.call(arguments,1);
return function(){
return fn.apply(context, args.concat(slice.call(arguments)));
};
};
Function.prototype.secondBind = function(context){
var fn = this, linked = [];
push.apply(linked, arguments);
linked.shift();
return function(){
var args = [];
push.apply(args, linked);
push.apply(args, arguments);
return fn.apply(context, args);
};
};
Function.prototype.bindThird = function (object) {
var originalFunction = this, args = slice.call(arguments), object = args.shift();
return function () {
return originalFunction.apply(object, args.concat(slice.call(arguments)));
};
};
Function.prototype.bindFourth = function(context){
var fn = this;
// Create an array of args to prepend
var a = new Array( arguments.length-1 );
for(var i = 1; i < a.length; ++i) a[i] = arguments[i];
return function(){
var args = new Array(a.length + arguments.length);
var i = 0;
for(; i < a.length; ++i) args[i] = a[i];
for(var n = 0; n < arguments.length; ++n, ++i) args[i] = arguments[n];
return fn.apply(context, args);
};
};
// test function and context
var testcxt = {},
testarg1 = 'test',
testarg2 = {},
testarg3 = 1,
testarg4 = {},
testfunc = function() {
},
testfunc1 = function() {
};
;
var first = testfunc.bindFirst(testcxt);
var second = testfunc.secondBind(testcxt);
var third = testfunc.bindThird(testcxt);
var native = testfunc.bind(testcxt);
var fourth = testfunc.bindFourth(testcxt);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
First |
| ready |
Second |
| ready |
Third |
| ready |
Native |
| ready |
Simplified |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.