Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Issue: string concatenation
Message
From
15/05/2005 12:10:23
 
 
To
15/05/2005 09:31:59
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01014342
Message ID:
01014352
Views:
24
>The manipulation of the VFP' STRINGS is not much efficient one,
>but the following code show a TOO MUCH inefficient execution.
>
>
>clear
>FOR K=1 TO 10000000
>NEXT
>
>y=SPACE(0)
>X=SPACE(16000000)
>
>t1=SECONDS()
>FOR K=1 TO 100
>	 =LEN(m.x)
>NEXT
>? "read result only",SECONDS()-t1
>
>t1=SECONDS()
>FOR K=1 TO 100
>	 =LEN(m.x+m.y)
>NEXT
>? "long+short is ok",SECONDS()-t1,"this read the long string, good !"
>
>t1=SECONDS()
>FOR K=1 TO 100
>	 =LEN(m.y+M.X)
>NEXT
>? "short+long IS BAD",SECONDS()-t1,"this read AND WRITE the long string,badly, much evil "
>
hi Fabio,

I suspect this is due to the fact that vfp can expand the string x in place, ie a realloc() without a memcpy

Watch the result below, Short + long is not necessarily slower
clear
FOR K=1 TO 10000000
NEXT

y=SPACE(1)
X=SPACE(3)

t1=SECONDS()
FOR K=1 TO 10000000
	 =LEN(m.x)
NEXT
? "read result only",SECONDS()-t1

t1=SECONDS()
FOR K=1 TO 10000000
	 =LEN(m.x+m.y)
NEXT
? "long+short is ok",SECONDS()-t1,"this read the long string, good !"

t1=SECONDS()
FOR K=1 TO 10000000
	 =LEN(m.y+M.X)
NEXT
? "short+long IS BAD",SECONDS()-t1,"this read AND WRITE the long string,badly, much evil "
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform