function calls: direct vs apply vs call vs bind (v24)

Revision 24 of this benchmark created on


Setup

function f() {
      return this;
    }
    var fc = f.call;
    var that = {
      f: f
    };
    var bound = f.bind(that);
    var that2 = Object.create(that);
    var that3 = {};
    var that4 = Object.create(that3);

Test runner

Ready to run.

Testing in
TestOps/sec
direct
that.f();
ready
apply
f.apply(that);
ready
call
f.call(that);
ready
bind
bound();
ready
prototype
that2.f();
ready
direct (dynamic property)
that3.f = f;
that3.f();
ready
prototype (dynamic property)
that3.f = f;
that4.f();
ready
fc();
ready

Revisions

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