bind vs closure (v31)

Revision 31 of this benchmark created by Gary on


Setup

var binder = function(scope, method) {
    return function() {
       return method.apply(scope, arguments);
    }
  };
  var binder2 = function(scope, method) {
    return function() {
       return method.call(scope);
    }
  };
  var self = this;
  var test = function() { return this; }
  
  var test_bind = test.bind(self);
  var test_self = function() { return self; };
  var test_binder = binder(self, test);
  var test_binder2 = binder2(self, test);
  
  var test_closure = function() { return closure(self, 5); };
  
  function closure(self, v) {
    return self;
  }

Test runner

Ready to run.

Testing in
TestOps/sec
call (control)
test.call(this);
ready
binder2
test_binder2();
ready
bind()
test_bind();
ready
self
test_self();
ready
closure
test_closure();
ready
binder
test_binder();
ready

Revisions

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