bind vs closure (v29)

Revision 29 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.1/dojo/dojo.js">
</script>
<script>
  function foo() {}
  bindtest = (function() {
     return this
   }.bind(this));
  hitchtest= dojo.hitch(this, function() {
  return this
});
</script>

Setup

var binder = function(scope, method) {
    return function() {
      return method.apply(scope, arguments);
    }
  };

Test runner

Ready to run.

Testing in
TestOps/sec
bind()
bindtest();
ready
self
var self = this;
var test = function() {
  return self
};
test();
ready
dojo.hitch
hitchtest();
ready
var test = binder(this, function() {
  return this
});
test();
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.