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 = 0, 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 valueReturns: 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
sleep(t: real, unit: TimeUnits = TimeUnits.seconds): void¶ Delay a task for a duration in the units specified
Arguments: - t : real -- The duration for the time to sleep
- unit :
TimeUnits-- The units for the duration
-
record
Timer¶ Implements basic stopwatch behavior with a potential resolution of microseconds if supported by the runtime platform.
The
Timercan be started, stopped, and cleared. ATimeris 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
startandstopsince the timer was created or the last call toclear. If the timer is running, the elapsed time since the last call tostartis added to the return value.Arguments: unit : TimeUnits-- The units for the returned valueReturns: The elapsed time in the units specified Return type: real(64)
-
proc