apply vs call vs invoke (v7)

Revision 7 of this benchmark created by JulienW on


Setup

var obj = {
      fn: function(a,b) {return a + b; }
    };
    
    var fn = obj.fn,
        fnBound = fn.bind(obj),
        fnJsBound = jsBind(obj, fn);
    
    function jsBind(self, fn) {
      return function() {
        return fn.apply(self, arguments);
       };
    }

Test runner

Ready to run.

Testing in
TestOps/sec
bind (native)
fnBound(1, 2);
ready
bind (js)
fnJsBound(1, 2);
ready
direct invoke
fn(1, 2);
ready
direct invoke on obj
obj.fn(1, 2);
ready

Revisions

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