[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: os.clock() always return 0 on Archlinux (a Linode instance)
- From: David Given <dg@...>
- Date: Tue, 27 Sep 2011 18:00:14 +0100
Johnson Lin wrote:
[...]
> And to my surprise, the tick returned by os.clock() is moving
> extremely slow, and if I make a burst of thousands of calls to
> os.clock(), it'll move a little bit faster (like 0.01 -> 0.02 -> 0.03
> every few "REAL" seconds), otherwise it'll simply return 0, as if
> the difference in time is not reportable by the function.
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.
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup
Attachment:
signature.asc
Description: OpenPGP digital signature