Module: Time¶
This module provides support for querying wall time in the local timezone and implements a record Timer that provides basic stopwatch behavior. The stopwatch has the potential for microsecond resolution and is intended to be useful for performance testing.
- enum TimeUnits { microseconds, milliseconds, seconds, minutes, hours }¶
Specifies the units to be used when certain functions return a time
- enum Day { sunday, monday, tuesday, wednesday, thursday, friday, saturday }¶
Specifies the day of the week
- proc getCurrentTime(unit: TimeUnits = TimeUnits.seconds): real(64)¶
Arguments: unit : TimeUnits – The units for the returned value Returns: The elapsed time since midnight, local time, in the units specified Return type: real(64)
- proc getCurrentDate()¶
Returns: (year, month, day) as a tuple of 3 ints The month is in the range 1 to 12. The day is in the range 1 to 31
- proc getCurrentDayOfWeek(): Day¶
Returns: The current day of the week Return type: Day
- proc sleep(t: uint): void¶
Delay a task for t seconds
- record Timer¶
Implements basic stopwatch behavior with a potential resolution of microseconds if supported by the runtime platform.
The Timer can be started, stopped, and cleared. A Timer is either running or stopped.
- proc clear(): void¶
Clears the elapsed time. If the timer is running then it is restarted otherwise it remains in the stopped state.
- proc start(): void¶
Starts the timer. It is an error to start a timer that is already running.
- proc stop(): void¶
Stops the timer. It is an error to stop a timer that is not running.
- proc elapsed(unit: TimeUnits = TimeUnits.seconds): real¶
Returns the cumulative elapsed time, in the units specified, between all pairs of calls to start and stop since the timer was created or the last call to clear. If the timer is running, the elapsed time since the last call to start is added to the return value.
Arguments: unit : TimeUnits – The units for the returned value Returns: The elapsed time in the units specified Return type: real(64)