call vs apply vs direct (v19)

Revision 19 of this benchmark created by James Wilkins on


Description

Test "call()" vs "apply()" vs calling functions directly.

Setup

function Obj() {
      this.that = "that";
    }
    Obj.prototype.test = function(val) {
      this.that = val;
    };
    var o = new Obj();

Test runner

Ready to run.

Testing in
TestOps/sec
apply
Obj.prototype.test.apply(o, ["YES"]);
ready
call
Obj.prototype.test.call(o, "YES");
ready
direct
o.test("YES")
ready

Revisions

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