[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: get time in ms?
- From: Jim Whitehead II <jnwhiteh@...>
- Date: Fri, 13 Nov 2009 13:13:26 +0000
On Fri, Nov 13, 2009 at 1:11 PM, Ico <email@example.com> wrote:
> * On 2009-11-13 steve donovan <firstname.lastname@example.org> wrote :
>> On Fri, Nov 13, 2009 at 3:02 PM, Andreas Krinke <email@example.com> wrote:
>> > os.clock() uses clock() from time.h which returns used processor time,
>> > not time since Lua started.
>> D:\downloads>lua -e "print(os.clock())"
> Your program just used 0 seconds of processor time.
> ico@lapdoos:~$ lua -e "a=1; for i = 1, 1000000 do a=a+1 end; print(os.clock())"
> This process was using the CPU for 0.09 seconds
> ico@lapdoos:~$ lua -e "os.execute('sleep 1'); print(os.clock())"
> And this one, although running for 1 second, used 0 seconds of CPU time
> as well. The os.execute() call blocks until the child process finishes,
> and blocking system calls do not use the CPU.
This is precisely why I use socket.gettime(). It gives you a number
with ms precision that you can then compare to determine how much real
time has passed.