cm0002@lemmy.world to Programmer Humor@programming.dev · 7 个月前timeoutSortlemmy.mlimagemessage-square35linkfedilinkarrow-up1484arrow-down14cross-posted to: programmerhumor@lemmy.ml
arrow-up1480arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 7 个月前message-square35linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squarerbnlinkfedilinkarrow-up33·7 个月前To reduce the chance of errors, you can multiply all numbers by a factor of 10, 100, 1000, 10000, … for the timeout. The higher the factor, the lower the chances of an incorrect result. And as no one asked about performance…
minus-squarefilcuk@lemmy.ziplinkfedilinkarrow-up35·7 个月前As added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!
minus-squarelugal@lemmy.dbzer0.comlinkfedilinkarrow-up5·7 个月前Better yet: take the square root and you get a sub-linear run time
minus-squareBlueKey@fedia.iolinkfedilinkarrow-up3·7 个月前Maybe not peak performance but heigh CPU efficency, it’s load ist mostly 0.
To reduce the chance of errors, you can multiply all numbers by a factor of 10, 100, 1000, 10000, … for the timeout. The higher the factor, the lower the chances of an incorrect result. And as no one asked about performance…
As added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!
Better yet: take the square root and you get a sub-linear run time
Maybe not peak performance but heigh CPU efficency, it’s load ist mostly 0.