jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Este pretende ser un caso básico para introducir el concepto de memoization.
function factorial(num) {
if (num === 0) {
return 1;
} else {
return num * factorial(num - 1);
}
}
function mejor_factorial(num) {
if (!mejor_factorial.cache) {
mejor_factorial.cache = {};
}
if (num === 0) {
return 1;
} else if (num in mejor_factorial.cache) {
return mejor_factorial.cache[num];
} else {
mejor_factorial.cache[num] = num * mejor_factorial(num - 1);
return mejor_factorial.cache[num];
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Factorial (sin memoization) |
| ready |
Factorial (con memoization) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.