Super Is Super Expensive

JavaScript performance comparison

Test case created by ssell

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  class Foo
  {
      constructor()
      {
          this.elapsed = 0;
      }
  
      update(delta)
      {
          this.elapsed += delta;
      }
  }
  
  class BarSuper extends Foo
  {
      update(delta)
      {
          super.update(delta);
      }
  }
  
  class BarPrototype extends Foo
  {
      update(delta)
      {
          Foo.prototype.update.call(this, delta);
      }
  }
  
  class BarDoItMyself extends Foo
  {
      update(delta)
      {
          this.elapsed += delta;
      }
  }

};
</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
Using Super
let bar = new BarSuper();
bar.update(1);
pending…
Using Prototype
let bar = new BarPrototype();
bar.update(1);
pending…
Updating Self
let bar = new BarDoItMyself();
bar.update(1);
pending…

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

Compare results of other browsers

0 Comments