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 scope = {
num: 2
};
var fn = function() {
return this.num + 1;
};
var emulateBind = function (fn, context) {
var curriedArgs = Array.prototype.slice.call(arguments, 2);
if (curriedArgs.length) {
return function () {
var allArgs = curriedArgs.slice(0);
for (var i = 0, n = arguments.length; i < n; ++i) {
allArgs.push(arguments[i]);
}
return fn.apply(context, allArgs);
};
}
else {
return createProxy(fn, context);
}
};
var createProxy = function(fn, context) {
return function() {
return fn.apply(context, arguments);
}
}
var simpleBind = function(fn, ctx) {
return function() {
return fn.apply(ctx, arguments);
};
};
</script>
var bound = fn.bind(scope),
simple = simpleBind(fn, scope),
emulated = emulateBind(fn, scope),
direct = function() {
return scope.num + 1;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Native bind |
| ready |
Emulated bind |
| ready |
Simple bind |
| ready |
Direct calling of scope |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.