function calls: direct vs apply vs call vs bind

JavaScript performance comparison

Revision 108 of this test case created by Grzegorz Michlicki

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const f = function(a, b, c) {
  this.a = a;
  this.b = b;
  this.c = c;
      return this;
  };
  
  const that = { f };
  
  const params = [1, 2, 3];
  
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
apply
f.apply(that, params);
pending…
bind
const bound = f.bind(that, ...params);
bound();
pending…
direct
that.f(...params);
pending…
call
f.call(that, ...params);
pending…

Compare results of other browsers

Revisions

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

0 Comments