Message
 
To
04/07/2020 00:06:20
General information
Forum:
Visual FoxPro
Category:
Third party products
Title:
Miscellaneous
Thread ID:
01674989
Message ID:
01675103
Views:
246
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  && to make sure it's getting hit the right amount of times!
	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 )
>
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View