MIRROR: javascript for 🐜's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

enhance performance logging

+26 -2
+1 -1
examples/demo/fibonacci_memo.js
··· 10 10 const end = performance.now(); 11 11 12 12 console.log(`fibonacci(621) = ${result}`); 13 - console.log(`Time: ${(end - start).toFixed(2)} ms`); 13 + console.log(`Time: ${(end - start).toFixed(4)} ms (${((end - start) * 1000).toFixed(2)} µs)`);
+1 -1
examples/demo/fibonacci_tco.js
··· 8 8 const end = performance.now(); 9 9 10 10 console.log(`fibonacci(30) = ${result}`); 11 - console.log(`Time: ${(end - start).toFixed(2)} ms`); 11 + console.log(`Time: ${(end - start).toFixed(4)} ms (${((end - start) * 1000).toFixed(2)} µs)`);
+1
src/ant.c
··· 7222 7222 tc_args = js->tc.args; 7223 7223 js->tc.args = NULL; 7224 7224 tc_argc = js->tc.argc; 7225 + tc_iter = true; 7225 7226 continue; 7226 7227 } 7227 7228
+23
tests/test_tco_zeroarg.js
··· 1 + // Test: verify zero-arg tail call actually uses TCO by going deep enough to 2 + // guarantee a stack overflow without it. 3 + 4 + // Pure zero-arg self-recursion with no parameters at all 5 + let n = 0; 6 + function go() { 7 + n++; 8 + if (n >= 1000000) return 'ok'; 9 + return go(); 10 + } 11 + const r = go(); 12 + console.log('result:', r, 'n:', n); 13 + if (r !== 'ok') { console.log('FAIL'); process.exit(1); } 14 + 15 + // Zero-arg mutual recursion 16 + let m = 0; 17 + function a() { m++; if (m >= 1000000) return m; return b(); } 18 + function b() { m++; if (m >= 1000000) return m; return a(); } 19 + const r2 = a(); 20 + console.log('mutual result:', r2); 21 + if (r2 !== 1000000) { console.log('FAIL'); process.exit(1); } 22 + 23 + console.log('PASS');