Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:48.0) Gecko/20100101 Firefox/48.0
Firefox 48
Mac OS X 10.11
Other
8 years ago
Test name Executions per second
Explicit call 37535296.0 Ops/sec
Apply call 7786941.0 Ops/sec
Apply with arguments call 1038364.7 Ops/sec
Script Preparation code:
x
 
function wrapExplicit(fn) {
  return function(a1, a2, a3) {
    return fn.call(this, this, a1, a2, a3)
  }
}
function wrapApply(fn) {
  return function() {
    var args = [this]
    for (let i = 0, len = arguments.length; i < len; i++) {
      args[i + 1] = arguments[i]
    }
    return fn.apply(this, args)
  }
}
function wrapApplyWithArguments(fn) {
  return function() {
    return fn.apply(this, [this].concat(arguments))
  }
}
function fn(thisArg, a1, a2, a3) {
  thisArg.result = a1 + a2 + a3
}
var explicitCall = { fn: wrapExplicit(fn) }
var applyCall = { fn: wrapApply(fn) }
var applyWithArgumentsCall = { fn: wrapApplyWithArguments(fn) }
Tests:
  • Explicit call

     
    explicitCall.fn(Math.random(), Math.random(), Math.random())
  • Apply call

     
    applyCall.fn(Math.random(), Math.random(), Math.random())
  • Apply with arguments call

     
    applyWithArgumentsCall.fn(Math.random(), Math.random(), Math.random())