[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: os.clock() always return 0 on Archlinux (a Linode instance)
- From: Rob Kendrick <rjek@...>
- Date: Tue, 27 Sep 2011 20:05:52 +0100
On Wed, Sep 28, 2011 at 01:10:23AM +0800, Johnson Lin wrote:
> On Wed, Sep 28, 2011 at 1:00 AM, David Given <email@example.com> wrote:
> > Yes. clock() does not return wall-clock time, it returns how much CPU
> > time your process is using, so if your process is blocked it won't
> > advance. As such it's not useful for anything much.
> > Go get luasocket and use socket.gettime() instead, it does the right thing.
> > --
> Thanks for the reply! I just found out os.clock() will be stalled by
> socket:settimeout() (however it won't on Windows, works fine.)
No, it works broken on Windows. The clock function returns how much
time your process has been running for. (And when you're stalled,
you're not running.) Back in the single-tasking DOS days, this had
precisely the same meaning as wall time your process had been running.
When Windows came along, they didn't fix this for the sake of
compatibility with old software.
If you need to know wall-clock time, get the wall-clock time :)