• making 1.85 billion copies of "27" via gawk in 714 ms

    From Kpop 2GM@21:1/5 to All on Sat May 28 04:35:36 2022
    624
    97968
    7249632
    14499264
    28998528
    57997056
    115994112
    231988224
    463976448
    927952896
    1855905792


    final length for [ "2727272727272727....2727272727272727" ] ::: 3711811584


    # gawk profile, created Sat May 28 07:22:45 2022

    # BEGIN rule(s)

    BEGIN {
    1 _ = (_ ^= __ = ____ = _ = 3) (_) (_) _
    1 _ = (_ = (_) (_) _) _
    1 ___ = "...."
    1 --__
    2 do {
    2 gsub(___, "&" _, _)
    2 print "", length(_)
    } while (--__)
    1 __ = (___) ___
    1 (gsub("", (__) (__) (__) __, __)) + (gsub("....", _, __))
    1 ____ *= ____
    1 _ = ""
    9 do {
    9 print "", length(__)
    9 __ = (__) __
    } while (--____)
    1 print sprintf("\n\n\t%.*sfinal length for [ \"%.*s....%s\" ] ::: %'.f\n\n", _ = _ < _, ___ = length(__), _ *= _ += _ += ++_, __, substr(__, -(--_ - ___)), ___)
    }

    ( LC_ALL=C gawk -p- -be ; ) 0.20s user 0.46s system 92% cpu 0.714 total

    ~~~~~~~~~~~~~~~~~~~

    Compared to gawk's interpreted scripting, even python3's built in replication feature isn't that much faster :

    3711811584

    ( LC_ALL=C python3 -c 'print(len("27"*1855905792))'; )
    0.11s user 0.25s system 98% cpu 0.373 total

    ~~~~~~~~~~~~~~~~~~~

    And for those days you want 15.4 billion copies of "9" using gawk ::

    168
    7224
    13053768
    965978832
    1931957664
    3863915328
    7727830656


    final length for [ "9999999999999999....9999999999999999" ] ::: 15455661312


    # gawk profile, created Sat May 28 07:33:29 2022

    # BEGIN rule(s)

    BEGIN {
    1 _ = (_ *= __ = ____ = _ = 3) (_) (_) _
    1 _ = (_ = (_) (_) _) _
    1 ___ = "...."
    1 __
    3 do {
    3 gsub(___, "&" _, _)
    3 print _____, length(_)
    } while (--__)
    1 __ = (___) ___
    1 (gsub(_____, (__) (__) (__) __, __)) + (gsub("....", _, __))
    1 ____ += ! (_ = "")
    4 do {
    4 print _, length(__)
    4 __ = (__) __
    } while (--____)
    1 print sprintf("\n\n\t%.*sfinal length for [ \"%.*s....%.*s\" ] ::: %'.f\n\n", _ = _ < _, ___ = length(__), _ *= _ += _ += ++_, __, _, substr(__, -(--_ - ___)), ___)
    }

    ( LC_ALL=C gawk -p- -be ; ) 1.43s user 2.07s system 98% cpu 3.559 total

    — The 4Chan Teller

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)