Skip to content

time

This content is for v1.0. Switch to the latest version for up-to-date documentation.

The time namespace provides timing primitives and thread sleeping. No import is required.


FunctionSignatureReturn TypeDescription
time.sleeptime.sleep(ms)voidPauses execution for the specified milliseconds (alias: sleep(ms)).
time.now_mstime.now_ms()numberReturns high-precision monotonic clock in milliseconds (alias: clock.ms()).
time.unix_mstime.unix_ms()numberReturns current Unix epoch time in milliseconds.

Suspends the running process or thread for ms milliseconds.

print("Starting countdown...");
var i = 3;
while (i > 0) {
print(str(i) + "...");
time.sleep(1000);
i = i - 1;
}
print("Launch!");

Returns the high-resolution monotonic time in milliseconds since system boot. Unaffected by system clock changes or daylight saving adjustments:

var start_ms = time.now_ms();
var i = 0;
while (i < 500000) { i = i + 1; }
var duration = time.now_ms() - start_ms;
print("Execution time: " + str(duration) + " ms");