15 lines
507 B
Lua
15 lines
507 B
Lua
-- Showcase the calog time library: read the real wall-clock epoch with
|
|
-- timeNow(), then measure a ~50ms timeSleep by sampling timeMonotonic()
|
|
-- before and after (monotonic is immune to wall-clock adjustments).
|
|
-- Run: bin/calog examples/scripts/libraries/time.lua
|
|
|
|
calogPrint("epoch now:", timeNow())
|
|
|
|
local start = timeMonotonic()
|
|
timeSleep(50)
|
|
local elapsed = timeMonotonic() - start
|
|
|
|
calogPrint("slept for (s):", elapsed)
|
|
calogPrint("about 0.05s:", elapsed >= 0.04 and elapsed < 0.5)
|
|
|
|
calogExit(0)
|