timer#

pybear.utilities.timer(orig_func)#

Wraps a function with a timer that displays the time in seconds it took for the function to run.

Parameters:
orig_funcCallable

Function to be timed when called.

Returns:
wrapperCallable

Wrapped original function.

Examples

>>> from pybear.utilities import timer
>>>
>>> @timer
... def my_function(x):
...     time.sleep(x)
...     return x
...
>>> my_function(1.28)
my_function ran in 1.28 sec
1.28