Rec

Benchmark created on


Setup

const arr = new Arr(100000)
for (let i = 0;i<arr.length;i++) {
	arr[i] = i + 1
}

Test runner

Ready to run.

Testing in
TestOps/sec
cahce ON
function checkWays(n,cache = []) {
  if (n<0) return 0
  if (n==0) return 1
  if(!cache[n]) {
    cache[n] = checkWays(n-1,cache) + checkWays(n-2,cache) + checkWays(n-3,cache)
  }
  return cache[n]
}

const n = Math.floor(Math.random() * arr.length)
checkWays(n,[])
ready
cahce OFF
function checkWays(n) {
  if (n<0) return 0
  if (n==0) return 1
  return checkWays(n-1) + checkWays(n-2) + checkWays(n-3)
}
const n = Math.floor(Math.random() * arr.length)
checkWays(n)
ready

Revisions

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