FunkUhr#

class stopuhr.FunkUhr(printer: callable = <built-in function print>)[source]#

Bases: object

Very high level benchmarking decorator.

Wraps the StopUhr class to provide a decorator for benchmarking functions.

Example

A stateful decorator exists as well, which is just a wrapper around the stateful timer. It supports the same arguments as the stateful timer.

>>> from stopuhr import FunkUhr

>>> funkuhr = FunkUhr()

>>> @funkuhr("Busy Function", log=False)
>>> def busy_function():
>>>     time.sleep(0.1)

>>> for i in range(5):
>>>     busy_function()

>>> funkuhr.summary()
Busy Function took 0.10 ± 0.00 s (n=5 -> total=0.50s)

Like the stateless decorator, it is possible to add arguments to the message.

It is also possible to add all arguments to the message.

export() pd.DataFrame[source]#

Export the durations as a pandas DataFrame.

Returns:

A pandas DataFrame with the durations.

Return type:

pd.DataFrame

summary(res: int = 2)[source]#

Print a summary of the durations.

Parameters:

res (int, optional) – The number of decimal places to round to. Defaults to 2.