Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Issue: string concatenation
Message
De
15/05/2005 12:10:23
 
 
À
15/05/2005 09:31:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01014342
Message ID:
01014352
Vues:
25
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform