>Craig,
>
>That appears to be true from the testing I've done here, but the difference you get is not really significant unless you're doing lots of processing within large loops.
>
>I ran the following code to test what would be a pretty far-fetched example:
>
#DEFINE PASSES 50
>
>create cursor Results(nWith N(15, 12), nWithout N(15, 12))
>for lnPass = 1 to PASSES
> m.j=0
> lnStart = Seconds()
> for m.i = 1 to 100000
> m.J = m.j + m.i
> endfor
> lnFinish = seconds()
>
> lnTotWith = lnFinish - lnStart
>
> m.j=0
> lnStart = Seconds()
> for m.i = 1 to 100000
> J = m.j + m.i
> endfor
> lnFinish = seconds()
>
> lnTotWithout = lnFinish - lnStart
>
> insert into results values(lnTotWith, lnTotWithout)
>endfor
>
>* analysis
>
>select avg(nWith) as AvgWith, avg(nWithout) as AvgWithout, max(nWith) as MaxWith, max(nWithout) as MaxWithout, ;
> min(nWith) as MinWith, min(nWithout) as MinWithout ;
> from results
>
>Results were:
>
AVGWITH AVGWITHOUT
> 0.332420000000 0.308900000000
> MAXWITH NWITHOUT
> 0.400000000001 0.351000000002
> MINWITH MINWITHOUT
> 0.320000000000 0.289999999997
>
>So, while the percentage difference seems like it might be significant (~10%), for 100,000 iterations, this is only 3/100ths of a second. Other optimisations are likely to be more helpful in terms of overall time for an operation.
>
>There are obviously cases where trimming the loop time by 10%
will make a significant difference, and it's worth being aware of this this behaviour in case you do come across one of those, but in the interests of consistency I'd generally try to use the m. on both sides of the equation and only remove it if optimisation is required.
>
>Cheers,
>
>Andrew
>
>>Just one other note...you should never use m. on the left side of and equal sign when using it as an assignment. You're code will run slower.
Andrew,
I've tested this in every version since 2.5 and continually get the same results. Lines with the m. take 3x longer to execute. This can show outside loops. If you have several assignment statements, you'll get a definate speed degradation.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer