Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.71 KB

File metadata and controls

44 lines (32 loc) · 1.71 KB

timeutil

LuaRocks Test Status Lua Versions Platform License

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.

✨ Features

  • 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.

📦 Installation

luarocks install timeutil

🚀 Usage

local 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()))