Artificial vs. Native Bind (v3)

Revision 3 of this benchmark created on


Description

Determine performance gains of native bind. Note: artificial bind doesn't support partial application.

Preparation HTML

<script>
  function artificial_bind(fn, context) {
   return function() {
    return fn.apply(context);
   }
  }

  var bind;

if(Function.prototype.bind){
        bind = function(fn, context){
                var prependArgs = Array.prototype.slice.call(arguments, 2);                             
                return fn.bind(context, prependArgs);
        };
}
  function test(arg) {
   var i;
   for (i = 0; i < 1000; i++) {
    arg += i;
   }
   this.lol = arg;

  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Artificial
artificial_bind(test, {})(1337)
ready
Native
bind(test,{})(1337);
ready

Revisions

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