bind (steady) vs closure (v45)

Revision 45 of this benchmark created by random 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);
    }
  };
  
  var testBind = function() {
    return this;
  }.bind(this);
  
  var self = this;
  var testSelf = function() {
      return self;
  };
  
  var testBinder = binder(this, function() {
    return this
  });

Test runner

Ready to run.

Testing in
TestOps/sec
bind()
testBind();
ready
self
testSelf();
ready
dojo.hitch
var test = dojo.hitch(this, function() {
  return this
});
test();
ready
binder
testBinder();
ready
call (control)
var test = function() {
  return this
};
test.call(this);
ready

Revisions

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