Timing
Module for timing things.
class Timer
dataclass
#
A timer for measuring the time between two events.
ATTRIBUTE | DESCRIPTION |
---|---|
start_time |
The time at which the timer was started.
TYPE:
|
kind |
The method of timing.
TYPE:
|
class Interval
dataclass
#
A time interval.
ATTRIBUTE | DESCRIPTION |
---|---|
start |
The start time.
TYPE:
|
end |
The end time.
TYPE:
|
kind |
The type of timer used.
TYPE:
|
unit |
The unit of time.
TYPE:
|
class Kind
#
An enum for the type of timer.
def from_str(key)
classmethod
#
Get the enum value from a string.
PARAMETER | DESCRIPTION |
---|---|
key |
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Kind | NAType
|
The enum value. |
Source code in src/amltk/profiling/timing.py
class Unit
#
An enum for the units of time.
def from_str(key)
classmethod
#
Get the enum value from a string.
PARAMETER | DESCRIPTION |
---|---|
key |
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Unit | NAType
|
The enum value. |
Source code in src/amltk/profiling/timing.py
def from_dict(d)
classmethod
#
Create a time interval from a dictionary.
Source code in src/amltk/profiling/timing.py
def na()
classmethod
#
Create a time interval with all values set to None
.
def time(kind='wall')
classmethod
#
Time a block of code.
PARAMETER | DESCRIPTION |
---|---|
kind |
The type of timer to use.
TYPE:
|
YIELDS | DESCRIPTION |
---|---|
Interval
|
The Time Interval. The start and end times will not be |
Interval
|
valid until the context manager is exited. |
Source code in src/amltk/profiling/timing.py
def start(kind='wall')
classmethod
#
Start a timer.
PARAMETER | DESCRIPTION |
---|---|
kind |
The type of timer to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Timer
|
The timer. |
Source code in src/amltk/profiling/timing.py
def stop()
#
Stop the timer.
RETURNS | DESCRIPTION |
---|---|
Interval
|
A tuple of the start time, end time, and duration. |