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.

at master 30 lines 554 B view raw
1const now = () => Date.now(); 2 3function bench(name, fn) { 4 const start = now(); 5 fn(); 6 const end = now(); 7 console.log(`${name}: ${end - start}ms`); 8} 9 10const digits = '9'.repeat(2000); 11const big = BigInt(digits); 12const big2 = big * big + 123456789n; 13 14bench('toString(10) x200', () => { 15 for (let i = 0; i < 200; i++) { 16 big2.toString(10); 17 } 18}); 19 20bench('toString(16) x200', () => { 21 for (let i = 0; i < 200; i++) { 22 big2.toString(16); 23 } 24}); 25 26bench('toString(2) x40', () => { 27 for (let i = 0; i < 40; i++) { 28 big2.toString(2); 29 } 30});