Test

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
without memoization
function fibonacci(n) {
	if (n <= 1) {
		return 1;
	}
	return fibonacci(n - 1) + fibonacci(n - 2);
}

fibonacci(20);
ready
with memoization
function fibonacci(n, cache = {}) {
	if (n <= 1) {
		return 1;
	}
	
	if (cache[n]) {
		return cache[n];
	}
	const result fibonacci(n - 1) + fibonacci(n - 2);
	cache[n] = result;
	return result;
}

fibonacci(20);
ready

Revisions

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