Decorator for measuring time¶
-
dlutils.timer.
timer
(f)[source]¶ Decorator for timeing function (method) execution time.
After return from function will print string:
func: <function name> took: <time in seconds> sec
.- Parameters
f (Callable[Any]) – function to decorate.
- Returns
Decorated function.
- Return type
Callable[Any]
Example
>>> from dlutils import timer >>> @timer.timer ... def foo(x): ... for i in range(x): ... pass ... >>> foo(100000) func:'foo' took: 0.0019 sec