Re: Delay()
- Posted by Hawke <mdeland at NWINFO.NET> Aug 15, 1998
- 429 views
twas I, and yes, you make a very good optimization that is also going to be put back in my toolbox as well. thanks for your sharp eye... and, yes, ticks count :) Mathew Hounsell wrote: > > Alan(?) Coded : > procedure Delay(atom seconds) > atom now > > now = time() > while (time() - now) < seconds do > end while > end procedure > > However this is more accurate : > > procedure Delay(atom seconds) > atom until > > until = time() + seconds > while time() < until do > end while > end procedure > > Why? Well the first version of delay is doing a function call, a load, a > calculation and then a comparison each time. > But calculations take time. > The second code does the calculation once. It then only does the function call > and comparison each time. > > The later is logically quicker. However it is all relative as no *human* would > percieve it. > A machine might. > > ----- > Sincerely, > Mathew Hounsell > Mat.Hounsell at Mailexcite.Com > > Free web-based email, Forever, From anywhere! > http://www.mailexcite.com