timeutil is a high-performance C-backed Lua module providing precision
wall-clock time, monotonic time, and sleep utilities.
Read the documentation to get started.
- Monotonic Clock: Measure precise intervals unaffected by NTP syncs or system clock shifts.
- Wall-Clock Time: Fetch system real-time with sub-microsecond precision.
- Fractional Sleep: Put the execution thread to sleep for fractional seconds without high CPU utilization.
- Multiple Lua Versions: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and 5.5.
luarocks install timeutillocal time = require "timeutil"
-- Measure precise elapsed time
local start = time.mono()
time.sleep(0.05) -- sleep for 50ms
local elapsed = time.mono() - start
print(string.format("Elapsed: %.6f seconds", elapsed))
print(string.format("Current Unix timestamp: %.6f", time.now()))