pydecorium.decorators.Timer#
To use the Timer
decorator, refer to the documentation Timer Usage.
- class pydecorium.decorators.Timer(*args, **kwargs)[source]#
Timer
class is a decorator that measures the runtime of a function.The
Timer
class is a sub-class of thepydecorium.decorators.ProfilerUtils
base class.The
data_name
attribute is set to “runtime”.Note
The runtime handle result is given in seconds. It can be summed to get the total runtime. The string_value method converts the result in hours, minutes and seconds.
- handle_result() float [source]#
Computes the runtime.
- Returns:
The runtime in seconds.
- Return type:
float
- post_execute(func, *args, **kwargs) None [source]#
Computes the runtime after the function execution.
- pre_execute(func, *args, **kwargs) None [source]#
Initializes the timer before the function execution.
- string_value(result) str [source]#
Converts the runtime in hours, minutes and seconds in the format “{hours}h {minutes}m {seconds}s”.
- Parameters:
result (float) – The runtime in seconds.
- Returns:
The runtime in hours, minutes and seconds.
- Return type:
str
- Raises:
TypeError – If result is not a numeric.