angular.bind vs custom vs native (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://code.angularjs.org/1.3.0-beta.17/angular.js"></script>

Setup

function bind1(self, fn) {
    return function() {
      fn.call(self, arguments);
    };
  }
  
  function bind2(self, fn) {
    return function() {
      fn.apply(self, arguments);
    };
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Angular.bind
var self = {};
function foo() {
}
var bound = angular.bind(self, foo);
ready
bind1
var self = {};
function foo() {
}
var bound = bind1(self, foo);
ready
bind2
var self = {};
function foo() {
}
var bound = bind2(self, foo);
ready
Native
var self = {};
function foo() {
}
var bound = foo.bind(self);
ready

Revisions

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

  • Revision 1: published by Jeff Cross on
  • Revision 2: published on
  • Revision 4: published by Wei Wayne Wang on