Function.prototype.bind

JavaScript performance comparison

Test case created and last updated

Preparation code

<script>
var nativeBind = Function.prototype.bind;
Function.prototype.bind = null;
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script>
var us = _.noConflict();
</script>
<script src="//rawgithub.com/es-shims/es5-shim/v2.3.0/es5-shim.js"></script>
<script>
Function.prototype.shimBind = Function.prototype.bind;
Function.prototype.bind = null;
</script>
<script src="//rawgithub.com/es-shims/es5-shim/v2.1.0/es5-shim.js"></script>
<script>
Function.prototype.oldShimBind = Function.prototype.bind;
Function.prototype.bind = nativeBind;
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script>
var ld = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var ld = window.ld,
        us = window.us;
   
    var func = function(key) { return ld.omit(this, key); },
        object = { 'a': 1, 'b': 2, 'c': 3 };
   
    var ldBound = ld.bind(func, object),
        ntBound = func.bind(object),
        omBound = func.oldShimBind(object),
        smBound = func.shimBind(object),
        usBound = us.bind(func, object);
   
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
lodash
ldBound('b');
pending…
native
ntBound('b');
pending…
shim
smBound('b');
pending…
old shim
omBound('b');
pending…
underscore
usBound('b');
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment