Time Module (time)
The time module provides functions for measuring time and performance.
Functions
time.now_ms()
Returns the current time in milliseconds. Useful for measuring execution time.
Returns:
number: The current timestamp in milliseconds.
Example:
let start = time.now_ms();
// ... do some work ...
let end = time.now_ms();
print("Work took", end - start, "ms");time.since_s(start_ms, precision)
Calculates the time elapsed in seconds since a given start time (in milliseconds), formatted to a specified decimal precision.
Arguments:
start_ms(number): The start time in milliseconds (usually obtained fromtime.now_ms()).precision(number): The number of decimal places for the seconds output.
Returns:
string|number: The elapsed time in seconds.
Example:
let start = time.now_ms();
// ... do some work ...
let elapsed = time.since_s(start, 3);
print("Elapsed:", elapsed, "s");