Skip to content

module time

Source: stdlib/time.codon


time()


time_ns()


monotonic()


monotonic_ns()


perf_counter()


perf_counter_ns()


sleep(secs: float)


TimeInterval

Utility class for timing Codon code

Fields

start: int

msg: str

Magic methods

__init__(self)

__enter__(self)

__exit__(self)

Methods

report(self, msg = "", memory = False)

elapsed(self)

tick(self, msg, memory = False)


timing(msg: str = "")

Example usage:

from time import timing
with timing('foo function'):
    foo()  # prints runtime of foo

struct_time @tuple Class is named tuple (cannot write fields)

Properties

tm_year @property Method is a class property

tm_yday @property Method is a class property

tm_sec @property Method is a class property

tm_min @property Method is a class property

tm_hour @property Method is a class property

tm_mday @property Method is a class property

tm_mon @property Method is a class property

tm_wday @property Method is a class property

tm_isdst @property Method is a class property

Magic methods

__new__(year: int = 0, mon: int = 0, mday: int = 0, hour: int = 0, min: int = 0, sec: int = 0, wday: int = 0, yday: int = 0, isdst: int = 0)


localtime(secs: int = -1)


gmtime(secs: int = -1)


mktime(t)