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 SecondsTo 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.