arrow-function-vs-closure-vs-bind

JavaScript performance comparison

Test case created by Alex Chao

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var module1 = {
    name: 'Foo',
    request: function () {
      var getName = () => this.name;
      getName();
    }
  };
  var module2 = {
    name: 'Foo',
    request: function () {
      var _this = this;
      var getName = function () { return _this.name; };
      getName();
    }
  };
  var module3 = {
    name: 'Foo',
    request: function () {
      var getName = function () { return this.name }.bind(this);
      getName();
    }
  };

};
</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
arrow-function
module1.request()
pending…
closure
module2.request()
pending…
bind
module3.request()
pending…

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

0 Comments