Time (std::time)

Read the device clock. This is useful for measuring how much time has elapsed between two points in your script.

Usage

The std::time library is available automatically. No import is required.

int t = std::time.now();

To schedule code to run later or repeatedly, use the language's timer keywords (after, every) rather than this library.

Functions

std::time.now(): int

Description: Returns the current device time as an integer. The exact unit and reference point are defined by the device firmware (typically a millisecond count since the device powered on), so treat the value as relative — capture it at two points and subtract to measure an elapsed duration.

int start = std::time.now();

// ... do some work ...

int elapsed = std::time.now() - start;
std::console.log("Elapsed:", elapsed);

Related