lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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.

┌─── ───── ─────
│ "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