1. time()

Robert, can we have a time(0) to reset time() to zero? 

Kat

new topic     » topic index » view message » categorize

2. Re: time()

Kat writes:
> Robert, can we have a time(0) to reset time() to zero? 

The value of time() was never guaranteed to be
zero at the start of execution. You should 
take the *difference* between two calls to time()
if you want to measure something. 
Adding an argument to time() would break a lot of code.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: time()

Kat wrote:
 
> Robert, can we have a time(0) to reset time() to zero? 

Kat, try please another function instead of time(),
for example :
-------------------
atom Time Time=0
function time_oper(integer t)
 if t=0 then
    Time=time() return 0
 else  
  return time()-Time
 end if
end function

? time_oper(0)

for i=1 to 10000000 do end for

? time_oper(1)

for i=1 to 10000000 do end for

? time_oper(2)
-------------------

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view message » categorize

4. 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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu