Delay()

new topic     » topic index » view thread      » older message » newer message

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

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu