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
How much overhead does a bind closure add?
var push = [].push,
slice = [].slice;
function bind(fn, thisArg) {
var curried, reset;
if (arguments.length > 2) {
curried = slice.call(arguments, 2);
reset = curried.length;
return function() {
curried.length = reset; // reset arg length
return fn.apply(thisArg, arguments.length
? (push.apply(curried, arguments), curried)
: curried
);
};
}
return function() {
return arguments.length
? fn.apply(thisArg, arguments)
: fn.call(thisArg);
};
};
function test() {
}
var context = {};
var bound = bind(test, context);
var partial = bind(test, context, 1);
if (test.bind) {
var nativeBound = test.bind(context);
var nativePartial = test.bind(context, 1);
}Ready to run.
| Test | Ops/sec | |
|---|---|---|
| native empty | | ready |
| simple empty | | ready |
| native args | | ready |
| simple args | | ready |
| native partial | | ready |
| simple partial | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.