call vs apply (v86)

Revision 86 of this benchmark created on


Setup

function Obj() {
      var that = "that";
    }
    Obj.prototype.target = function(arg) {
      var string = "that: " + this.that + ", arg: " + arg;
      return string;
    };
    
    var myObj = new Obj();

Test runner

Ready to run.

Testing in
TestOps/sec
Call
var that = {
  that: "that"
};
var arg = "arg";
Obj.prototype.target.call(null);
ready
Apply
var that = {
  that: "that"
};
var arg = "arg";
Obj.prototype.target.apply(null);
ready
Normal invocation
var arg = "arg";
new Obj().target(arg);
ready
Normal invocation cached Obj
var arg = "arg";
myObj.target(arg);
ready

Revisions

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