powerRecursive

Benchmark created by Robert Green on


Description

Test recursive power function versus iterative

Preparation HTML

<script>
  function power(base, exponent) {
    return exponent == 0? 1 : base * power(base, exponent - 1);
  }
  
  function powerNR(base, exp) {
    var result = 1;
    while(exp--) {
      result *= base;
    }
    return result;
  }
  var x = 5, y = 11;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Recursive
power(x, y)
ready
Iterative
powerNR(x, y)
ready

Revisions

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

  • Revision 1: published by Robert Green on