Skip to content

time

This content is for v0.2.1. Switch to the latest version for up-to-date documentation.

The time namespace provides timing primitives and thread sleeping.


FunctionSignatureReturn TypeDescription
time.sleeptime.sleep(ms)voidPauses execution for the specified milliseconds.
time.mstime.ms()numberReturns monotonic system milliseconds counter.

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("Liftoff!");

Returns the high-resolution monotonic time in milliseconds since system boot. Unaffected by system clock changes or daylight saving adjustments, making it ideal for games, animations, and benchmarking:

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