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

Re: delimiters with more than one character? ...



On Thu, Aug 06, 2020 at 11:57:47AM +0900, John Crawley wrote:
> I likely don't have a sufficient grasp of that "spirit" to comment there :)
> but as for "hideously slow", remain to be convinced. Bash string
> modifications seem to be pretty fast. Would very long strings requiring
> multiple runs of the loop slow it down excessively?

Absolutely.

> Adding this:
> 
> for i in {1..10}
> do
>     _S+=$del$_S
> done
> 
> to multipy the string by 1024 gave times of ~3.9s and ~4.0s.

For short strings, doing this sort of parsing in bash is fine.  But as
you can see, on large inputs, it does not scale well.  The fact that each
iteration makes a *copy* of nearly the entire remaining input doesn't
help matters, either -- right off the bat, that algorithm makes the run
time explode, even before you take into account bash's 100% interpreted
runtime slowness.


Reply to: