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 src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
var sum = function(x) {
return this + x;
}
var bind = function(fn, context) {
var slice = Array.prototype.slice,
args = slice.call(arguments, 2);
return Function.prototype.bind ? fn.bind(context, args) : function() {
return fn.apply(
context,
args.concat(slice.call(arguments))
)
};
};
var bind2 = function( /* Function */ fn, /* * */ context) {
if (Function.prototype.bind) {
return fn.bind(context, Array.prototype.slice.call(arguments, 2));
}
return function() {
return fn.apply(
context,
args.concat(Array.prototype.slice.call(arguments))
)
};
};
var bind3 = function( /* Function */ fn, /* * */ context) {
return fn.bind ? fn.bind(context, Array.prototype.slice.call(arguments, 2)) : function() {
return fn.apply(
context,
args.concat(Array.prototype.slice.call(arguments))
)
};
};
var bind4 = function( /* Function */ fn, /* * */ context) {
var slice = Array.prototype.slice,
args = slice.call(arguments, 2);
return fn.bind ? fn.bind(context, args) : function() {
return fn.apply(
context || this,
args.concat(slice.call(arguments))
)
};
};
var bind5 = function( /* Function */ fn, /* * */ context) {
var slice = Array.prototype.slice,
args = slice.call(arguments, 2);
return function() {
return fn.apply(
context || this,
args.concat(slice.call(arguments))
)
};
};
var bind6 = function( /* Function */ fn, /* * */ context) {
// Return undefined instead of throwing an exception
if (typeof fn != 'function') {
return undefined;
}
var slice = Array.prototype.slice,
args = slice.call(arguments, 2);
return fn.bind ? fn.bind(context, args) : function() {
return fn.apply(
context || this,
args.concat(slice.call(arguments))
)
};
};
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery.proxy |
| ready |
Custom bind |
| ready |
Native Bind |
| ready |
Custom bind 2 (No vars) |
| ready |
Custom bind 3 (Function.prototype.bind or native) |
| ready |
Custom bind 4 (.bind or native) |
| ready |
Custom bind 5 (Only native) |
| ready |
Custom bind 6 (Only native w/ callable check) |
| ready |
Underscore bind |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.