cm0002@lemmy.world to Programmer Humor@programming.dev · 11 days agotimeoutSortlemmy.mlimagemessage-square10linkfedilinkarrow-up13arrow-down10
arrow-up13arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 11 days agomessage-square10linkfedilink
minus-squareNat (she/they)@lemmy.blahaj.zonelinkfedilinkarrow-up0·11 days agoWait till you find out how the runtime manages multiple concurrent timers
minus-squaresus@programming.devlinkfedilinkarrow-up0·11 days agoit’s while (true) { let t = Date.now(); if (timeoutMap.has(t)) timeoutMap[t](); } of course. Clearly O(n). disclaimer Feel free to use it. I guarantee it is bug free. Comes with express warranty. This notice is legally binding.
minus-squareFooBarrington@lemmy.worldlinkfedilinkarrow-up1·10 days agoI found a way to optimize your code without affecting the result. By making it branchless, I was able to get my CPU to 100% utilization!
Wait till you find out how the runtime manages multiple concurrent timers
it’s
while (true) { let t = Date.now(); if (timeoutMap.has(t)) timeoutMap[t](); }of course. Clearly O(n).
disclaimer
Feel free to use it. I guarantee it is bug free. Comes with express warranty. This notice is legally binding.
I found a way to optimize your code without affecting the result. By making it branchless, I was able to get my CPU to 100% utilization!