func_running_time¶
- pyhelpers.ops.func_running_time(func)[source]¶
Decorator to measure the execution time of a function or class method.
- Parameters:
func (Callable) – Function or class method to be decorated.
- Returns:
Decorated function or class method that measures its own execution time.
- Return type:
Callable
Examples:
>>> from pyhelpers.ops import func_running_time >>> import time >>> @func_running_time >>> def test_func(): ... print("Testing if the function works.") ... time.sleep(3) >>> test_func() INFO Begin to run function: test_func … Testing if the function works. INFO Finished running function: test_func, total: 3s