[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to Generate a Long String of the Same Character
From: |
Neil R. Ormos |
Subject: |
Re: How to Generate a Long String of the Same Character |
Date: |
Mon, 19 Jul 2021 01:46:40 -0500 (CDT) |
Bob Proulx wrote:
> That's looking pretty good. Let's compare it against the reference
> above so one can see how slow my machine is about such things.
>
> $ time awk 'BEGIN{sizelim=100000000; a="x"; while (length(a) < sizelim)
> {a=a a}; a=substr(a, 1, sizelim); print length(a);}'
>
> 100000000
>
> real 0m1.469s
> user 0m0.815s
> sys 0m0.654s
>
> I am running this on an older Intel Core i5 CPU 750 2.67GHz.
That seems really odd. It takes under 0.5 seconds
of elapsed time on a machine with a 25-watt mobile
Core 2 Duo CPU that maxes out at 2.26 GHz.
I tried your dd | tr | gawk solution and found the
times vary bizarrely on machines where the pure
gawk solution has run-times roughly in-line with
what I'd expect. Even the elapsed times of
consecutive individual runs of the dd | tr | gawk
solution vary strangely.
Also, I think the blocksize parameter should be
bs=1MB to get blocks of 10^6 bytes and not 2^20
bytes.