fibo-algo

Benchmark created by Hector Zarco on


Preparation HTML

<script>
function fiboLoop(num){
  var a = 1, b = 0, temp;

  while (num >= 0){
    temp = a;
    a = a + b;
    b = temp;
    num--;
  }

  return b;
}

function fiboRec(num) {
  if (num <= 1) return 1;

  return fiboRec(num - 1) + fiboRec(num - 2);
}

function fiboMemo(num, memo) {
  memo = memo || {};

  if (memo[num]) return memo[num];
  if (num <= 1) return 1;

  return memo[num] = fiboMemo(num - 1, memo) + fiboMemo(num - 2, memo);
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Loop
fiboLoop(20)
ready
Recursive
fiboRec(20)
ready
Memoization
fiboMemo(20)
ready

Revisions

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

  • Revision 1: published by Hector Zarco on
  • Revision 10: published by Stephen Turner on
  • Revision 14: published by Johnson Chen on