lights FAQ Forum

Portable OS APIs


time and sleeping

local time = require'time'


time.time() -> n wall clock time with ~100us precision
time.clock() -> n monotonic time in seconds with ~1us precision
time.sleep(s) sleep with sub-second precision (~10-100ms)

time.time() -> n

Reads the wall-clock time as a UNIX timestamp. It is the same as the time returned by os.time() on all platforms, except it has sub-second precision. It is affected by drifting, leap seconds and time adjustments by the user. It is not affected by timezones. It can be used to synchronize time between different boxes on a network regardless of platform.

time.clock() -> n

Reads a monotonic performance counter, and is thus more accurate than time.time(), it should never go back or drift, but it doesn't have a fixed time base between program executions. It can be used for measuring short time intervals for thread synchronization, etc.

Last updated: 16 months ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r1-8-g603de2a
Last commit:
License: PD
Requires: luajit 
Required by: nw  xlib