bind vs closure (v27)

Revision 27 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js">
</script><script src="http://documentcloud.github.io/underscore/underscore-min.js"></script>
<script>
  function foo() {}
</script>

Setup

var binder = function(scope, method) {
      return function() {
         return method.apply(scope, arguments);
      }
    };
    
    var self = this;
    var test = function() { return this; }
    
    var test_bind = test.bind(self);
    var test_self = function() { return self; };
    var test_dojo = dojo.hitch(self, test);
    var test_binder = binder(self, test);
    var test_underscore = _.bind(test, self);
    var test_assign = test;

Test runner

Ready to run.

Testing in
TestOps/sec
bind()
test_bind();
ready
self
test_self();
ready
dojo.hitch
test_dojo();
ready
binder
test_binder();
ready
call (control)
test.call(this);
ready
underscore
test_underscore()
ready
Simple assignation
test_assign()
ready

Revisions

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