time()
Peoples,
Somebody asked about using time(). To
use time you need an atom and you
need to go <variable> = time() then
use time() and the variable together.
Try this:
---Snip---
procedure timecode()
atom time_then, time_taken
time_then = time()
-- code to execute.
time_taken = time() - time_then
print(1,time_taken)
end procedure
----------
The above code will tell you how long
code takes.
Or try this:
---Snip---
procedure timecode()
atom time_then, time_taken
time_then = time()
for t = 1 to 1000 by 1 do
-- code to execute.
end for
time_taken = time() - time_then
print(1,time_taken/1000)
end procedure
----------
This is better as it gives an average.
Or this:
---Snip---
include machine.e
tick_rate(100)
procedure timecode()
atom time_then, time_taken
time_then = time()
for t = 1 to 1000 by 1 do
-- code to execute.
end for
time_taken = time() - time_then
print(1,time_taken/1000)
end procedure
----------
This is more accurate.
Or you could do something like this
---Snip---
procedure wait()
atom time_then
time_then = time()
while time()- time_then < 5 do
-- code if wanted
end while
----------
This will loop for five seconds.
Or I often do this
---Snip---
procedure do()
atom time_then
time_then = time()
while 1 do
if time() - time_then = 1 then
--code
time_then = time()
end if
end while
end procedure
----------
Bye.
Sincerely,
Mathew Hounsell
Mat.Hounsell at mailexcite.com
Free web-based email, Forever, From anywhere!
http://www.mailexcite.com
|
Not Categorized, Please Help
|
|