lights FAQ Forum

Portable OS APIs
fs WIP
nw WIP
libsoundio WIP
videoinput WIP


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: 2 years ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r1-9-g0041fbf
Last commit:
License: PD
Requires: luajit 
Required by: nw  cplayer  ui  xlib