11# timeutil
22
3+ [ ![ Test] ( https://img.shields.io/github/actions/workflow/status/BlueLua/timeutil/test.yml?branch=main&label=test&style=flat-square )] ( https://github.com/BlueLua/timeutil/actions/workflows/test.yml )
34[ ![ LuaRocks] ( https://img.shields.io/luarocks/v/BlueLua/timeutil?color=blue&style=flat-square )] ( https://luarocks.org/modules/BlueLua/timeutil )
45![ Lua Versions] ( https://img.shields.io/badge/lua-5.1%20%7C%205.2%20%7C%205.3%20%7C%205.4%20%7C%205.5%20%7C%20LuaJIT-blue?style=flat-square )
56![ Platform] ( https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square )
67[ ![ License] ( https://img.shields.io/badge/license-MIT-blue?style=flat-square )] ( https://github.com/BlueLua/timeutil/blob/main/LICENSE )
78
8- ` timeutil ` is a high-performance C-backed Lua module providing precision
9- wall-clock time, monotonic time, and sleep utilities.
9+ High-performance C-backed Lua module for precision wall-clock time, monotonic
10+ time, and sleep utilities.
11+
12+ Check out the [ documentation] for guides and examples.
1013
1114## ✨ Features
1215
13- - ** Monotonic Clock** : Measure precise intervals unaffected by [ NTP ] syncs or
14- system clock shifts .
16+ - ** Monotonic Clock** : Measure precise intervals unaffected by system clock
17+ shifts or NTP syncs .
1518- ** Wall-Clock Time** : Fetch system real-time with sub-microsecond precision.
16- - ** Fractional Sleep** : Put the execution thread to sleep for fractional seconds
17- without high CPU utilization.a
19+ - ** Fractional Sleep** : Sleep for fractional seconds without busy-waiting or
20+ high CPU utilization.
1821- ** Multiple Lua Versions** : Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
1922 5.5.
23+ - ** Cross-Platform** : Works consistently across Windows, macOS, and Linux.
2024
2125## 📦 Installation
2226
@@ -27,15 +31,15 @@ luarocks install timeutil
2731## 🚀 Usage
2832
2933``` lua
30- local time = require " timeutil"
34+ local timeutil = require " timeutil"
3135
3236-- Measure precise elapsed time
33- local start = time .mono ()
34- time .sleep (0.05 ) -- sleep for 50ms
35- local elapsed = time .mono () - start
37+ local start = timeutil .mono ()
38+ timeutil .sleep (0.05 ) -- sleep for 50ms
39+ local elapsed = timeutil .mono () - start
3640
37- print (string.format (" Elapsed: %.6f seconds" , elapsed ))
38- print (string.format (" Current Unix timestamp: %.6f" , time .now ()))
41+ print (string.format (" Elapsed:%.6f seconds" , elapsed ))
42+ print (string.format (" Current Unix timestamp: %.6f" , timeutil .now ()))
3943```
4044
41- [ NTP ] : https://en.wikipedia.org/wiki/Network_Time_Protocol
45+ [ documentation ] : https://bluelua.github.io/timeutil
0 commit comments