Skip to content

BlueLua/timeutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

C-backed Lua module for wall-clock time, monotonic time, and blocking sleep.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors