cm0002@lemmy.world to Programmer Humor@programming.dev · 8 months agotimeoutSortlemmy.mlexternal-linkmessage-square29linkfedilinkarrow-up1328arrow-down12
arrow-up1326arrow-down1external-linktimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 8 months agomessage-square29linkfedilink
minus-squaresus@programming.devlinkfedilinkarrow-up6·8 months 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-squareyetAnotherUser@lemmy.calinkfedilinkarrow-up2·8 months agoThen don’t complain once you get arrested…
minus-squareFooBarrington@lemmy.worldlinkfedilinkarrow-up1·8 months 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!
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.
Then don’t complain once you get arrested…
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!