Skip to main content
Log in

Mojo module

time

Implements basic utils for working with time.

You can import these APIs from the time package. For example:

from time import perf_counter_ns
from time import perf_counter_ns

Functions

  • monotonic: Returns the current monotonic time time in nanoseconds. This function queries the current platform's monotonic clock, making it useful for measuring time differences, but the significance of the returned value varies depending on the underlying implementation.
  • perf_counter: Return the value (in fractional seconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between the results of two calls is valid.
  • perf_counter_ns: Return the value (in nanoseconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between the results of two calls is valid.
  • sleep: Suspends the current thread for the seconds specified.
  • time_function: Measures the time spent in the function.