Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hello m.World
Message
 
To
22/04/2000 17:49:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00362492
Message ID:
00362546
Views:
20
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.


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform