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

Revision 93 of this benchmark created by pusha on


Preparation HTML

<script>
function Entity(x) {
  this.x = x;
}

Entity.prototype.f = function(y) {
  return this.x * y;
};

var obj = new Entity(42);
var fc = Entity.prototype.f;
var fb = Entity.prototype.f.bound(obj);
var fw = function () {
  obj.f(1);
};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
direct
obj.f(1);
ready
call
fc.call(obj, 1);
ready
bind
fb(1);
ready
wrap
fw(1);
ready

Revisions

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