lua-users home
lua-l archive

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

Wouldn't this even be worthy of mentioning on the Lua manual page, if really so (that for Windows it's not the CPU time).

Also, ability of reading wall clock time in ms would be a nice addition in Lua _itself_. It would need a small C function with one ifdef. No need to remind it's not ANSI C - I think some exceptions to that rule could really be worth it.


Cheng, Long kirjoitti 16.11.2009 kello 4:40:

The POSIX standard specifies os.clock() returning CPU time used. But microsoft POSIX library os.clock() returns wall time elapsed since the process started. You'd better avoid using it when your lua code is supposed to run both on Windows and Linux. We learned this a hard way.


Asko Kauppi 写道:

Notice that the value returned by os.clock() is:

".. approximation of the amount in seconds of CPU time used by the program."

It is not the "wall clock" time. If you need that in ms, you need to use LuaSocket, Lanes or some other C side binding to gettimeofday (2) on Posix and similar Win32 API.


spir kirjoitti 13.11.2009 kello 14:37:

Hello again,

Is there a builtin or a lib tool? If not, how do you do it?
(googling brought no sensible info on the topic)

Thank you,
* la vita e estrany *