bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gsub() is very slow in gawk 5.1.0


From: Neil R. Ormos
Subject: Re: gsub() is very slow in gawk 5.1.0
Date: Wed, 14 Jul 2021 17:33:54 -0500 (CDT)

Ed Morton wrote:

> On an online forum someone asked how to generate
> a string of 100,000,000 "x"s.  They had tried
> this in a BEGIN section:

>    for(i=1;i<=100000000;i++) s = s "x"

> and wanted to know if there was a better
> approach. Someone suggested:

>    s=sprintf("%*s",1000000000,""); gsub(/ /,"x",s)}

> which is also what I'd have also suggested, but
> upon testing that they found that the
> sprintf+gsub approach was slower than the loop
> in gawk 5.1.0 and while I couldn't reproduce
> that exactly on cygwin, I can confirm that the
> sprintf+gsub solution is much slower than I
> expected: [...]

I thought the original question was interesting,
so I addressed it on the help-gawk@gnu.org list.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]