|
From: | Ed Morton |
Subject: | Re: gsub() is very slow in gawk 5.1.0 |
Date: | Wed, 14 Jul 2021 18:47:54 -0500 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 7/14/2021 5:33 PM, Neil R. Ormos wrote:
Thanks Neil - I personally wont be looking at anything on help-gawk but if you'd like to respond to the question that prompted the bug report, it's at https://stackoverflow.com/q/68371275/1745001.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.
Ed.
[Prev in Thread] | Current Thread | [Next in Thread] |