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
/**
* Trampoline 函数,将尾递归函数转换成循环
*/
function trampoline(fn) {
return function(...args) {
let result = fn(...args);
while (typeof result === 'function') {
result = result();
}
return result;
};
}
// 输入
const input = 0
const maxNum = 5000000;
Ready to run.
Test | Ops/sec | |
---|---|---|
标准尾调用优化 |
| ready |
使用Trampoline 转换后的尾调用 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.