cache this members-test

Benchmark created on


Preparation HTML

<script>
  var Base2 = {
    base: 2,
    exponent: function(power) {
      var result = 1;
      for (var i = 0; i < power; i++) {
        result *= this.base;
      }
      return result;
    },
    exponentCacheBase: function(power) {
      var result = 1;
      var base = this.base;
      for (var i = 0; i < power; i++) {
        result *= base;
      }
      return result;
    }
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
No caching of this.base
Base2.exponent(10);
 
ready
this.base is cached
Base2.exponentCacheBase(10);
 
ready

Revisions

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