>Hmmm... great idea. Yeah that might work although a little involved if you need to make this more generic for size.
>
>This works:
>
>
>lnSecs = SECONDS()
>
>lnCount = 0
>n = 0
>lnBuffer = 3500
>FOR n = 0 TO 9999999999
> j = SUBSTR(m.lcString,(n*lnBuffer)+1,lnBuffer)
> lnLen = LEN(j)
> IF (lnLen < 1)
> EXIT
> ENDIF
> For lnX = 1 To lnLen
> lcVal = Substr(m.j,lnX,1)
> * lnCount = lnCount + 1
> Endfor
>ENDFOR
>
>* 0.32 seconds
>? "String Splitting: " + TRANSFORM( SECONDS() - lnSecs ) + " " + TRANSFORM(lnCount)
>
>
>Also playing around with the buffer size - looks like on my machine ~3500 chars seems to work best. Over 5000 it starts slowing down. Under 2,000 it slows down too although not much on that end.
>
>Also interesting - see the `lnCount` in there? If I leave the counter in there times nearly double!
>
>Great thinking. I'll update the blog post (with credit to you)... Thank you!
>
>+++ Rick ---
>
>>
>>* 1mb string
>>Local lnX, lcString
>>lcString = Replicate("1234567890",100000)
>>
>>lnLength = Len(lcString)
>>? "Iterations: " + Transform(lnLength,"9,999,999")
>>
>> lnSecs = Seconds()
>>
>>FOR n = 0 TO 999
>> j = SUBSTR(m.lcString,(n*1000)+1,1000)
>> For lnX = 1 To 1000
>> lcVal = Substr(m.j,lnX,1)
>> Endfor
>>endfor
>>
>> ? "SUBSTR: " + Transform(Seconds() - lnSecs )
>>
>>
Yes.. for this test any exec code you run will have to execute a million times..!
In my experience with nfJson , using alines() to split the string by control
characters ( ,;[] " ) and then work in chunks was the key to speed.. I think
any big string manipulation should be tuned for each case..
Anyway, it's always good to share this little findings. !
@nfoxdev
github.com/nfoxdev