• wise_pancake@lemmy.ca
      link
      fedilink
      arrow-up
      39
      arrow-down
      1
      ·
      1 month ago

      I have a great performance optimization for this

      What if instead of 1s sleep, we did 0.5s sleep? That’s a 100% improvement.

    • devfuuu@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      1 month ago

      For anyone who controls time travel this is the fastest algorithm ever. Probably gonna change everything when we are traveling through space and passing by some dark holes.

    • morrowind@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      Even as a joke, this doesn’t avoid anything. The system scheduler just has to do the sorting using a regular algorithm

    • idunnololz@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      The output isn’t guaranteed to be correct though. Most implementations of sleep can only guarantee that it will sleep for at least the amount of time specified. It can sleep for longer though.