bind vs closure (v10)

Revision 10 of this benchmark created by Arthur on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js">
</script>
<script>
  function foo() {}
</script>

Setup

var binder = function(scope, method) {
      return function() {
        return method.apply(scope, arguments);
      }
      },
      target = {};
  
  var test1 = function() {
      return this;
      }.bind(target);
  
  var test2 = function() {
      return target;
      };
  
  var test3 = dojo.hitch(target, function() {
    return this;
  });
  
  var test4 = binder(target, function() {
    return this;
  });
  
  var test5 = function() {
      return this;
      };

Test runner

Ready to run.

Testing in
TestOps/sec
bind()
test1();
ready
self
test2();
ready
dojo.hitch
test3();
ready
test4();
ready
call (control)
test5.call(target);
ready

Revisions

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