Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
M. performance
Message
De
23/04/2002 12:18:53
 
 
À
23/04/2002 11:30:48
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00647967
Message ID:
00648248
Vues:
30
Mike
I , like Sergey, use m. to reference variables as a general rule. I had heard many times that there was a slight performance hit, but I have found it to be better to avoid problems. This thread got me curious, so I wrote a little test program to check.
m.test1 = 0
m.test2 = 0
m.test3 = 0
m.test4 = 0
m.test5 = 0
m.test6 = 0

m.seconds1 = seconds()

for m.xx = 1 to 500000
	m.test1 =  m.test1+1
	m.test2 =  m.test2+1
	m.test3 =  m.test2 +1
	m.test4 =  m.test4+1
	m.test5 =  m.test5+1
	m.test6 =  m.test6 +1
next
?strtofile("using m. for all variables in 1 to  500000 loop"+chr(13)+chr(10),"test.txt",.t.)
?strtofile(alltrim(str(seconds()-m.seconds1,10,3))+" Seconds"+chr(13)+chr(10),"test.txt",.t.)
test1 = 0
test2 = 0
test3 = 0
test4 = 0
test5 = 0
test6 = 0
seconds1 = seconds()

for xx = 1 to 500000
	test1 =   test1+1
	test2 =   test2+1
	test3 =   test2+1
	test4 =   test4+1
	test5 =   test5+1
	test6 =   test6 +1
next
?strtofile("NOT using m. for all variables in 1 to  500000 loop"+chr(13)+chr(10),"test.txt",.t.)
?strtofile(alltrim(str(seconds()-m.seconds1,10,3))+" Seconds"+chr(13)+chr(10),"test.txt",.t.)
Results using P4 1.8Ghz 256MB VFP 6.0 SP5
Using m. for all variables in 1 to  500000 loop
1.892 Seconds
NOT using m. for all variables in 1 to  500000 loop
1.803 Seconds

Using m. for all variables in 1 to  1000000 loop
3.775 Seconds
NOT using m. for all variables in 1 to  1000000 loop
3.566 Seconds

Using m. for all variables in 1 to  1500000 loop
5.668 Seconds
NOT using m. for all variables in 1 to  1500000 loop
5.298 Seconds
To me this difference in performance is neglible compared to the benefits that I have found in readablilty of code and preventing ambiguity and confusion especially when looking at code some years later.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform