• wise_pancake@lemmy.ca
    link
    fedilink
    arrow-up
    40
    ·
    3 days 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.

      • JackbyDev@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 day ago

        I took it as meaning sleep for a number of seconds equal to half the value you’re sorting. So like f "(( $1 / 2 ))" & or however math works in bash, I always forget.

            • Amanduh@lemm.ee
              link
              fedilink
              arrow-up
              1
              ·
              1 day ago

              I bet you also tell people you love regex because you think it makes you look smarter lol

              • JackbyDev@programming.dev
                link
                fedilink
                English
                arrow-up
                2
                ·
                22 hours ago

                Well, maybe not with regex, but I’d be lying if I said I never get satisfaction things like that lol. Bash and regex both are very useful tools, great at what they do, but have some design choices that make them annoying. That’s sort of what I was trying to get at by saying “yes but also skill issue” lol. A good example is iterating over output in bash. I have zero confidence it’s going to do anything remotely close to what I want and have to look up stuff every time I’m trying to do it. “Is it going to go word by word? Line by line? Are there null byte separators?” PowerShell seems appealing in that regard because it works with objects instead of text, but I haven’t really used it in depth and I don’t see myself going through it just to see if it’s worth trying to use more often.

      • lurch (he/him)@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        3 days ago

        the idea isn’t wrong tho, as sleep can do fractions. bash cannot though. therefore it would bloat the code a bit to use bc to multiply the parameter by 0.5 or so.