A simple package with a few method to get the execution time of methods through wrapping.
Currently, the package contains two methods, one which returns to sdout (print) and one which goes to a logger. The method prints the time in a nice way, i.e. milliseconds, seconds, minutes or hours. For example:
from execution_time_wrapper import get_execution_time_print, get_execution_time_log
@get_execution_time_print
def my_fun():
print("Hello World!")
my_fun()
>> Hello World!
>> Computation time for my_fun: 0.02 ms
However, if the function takes more time:
from execution_time_wrapper import get_execution_time_print, get_execution_time_log
from time import sleep
@get_execution_time_print
def my_fun():
sleep(4)
print("Hello World!")
my_fun()
>> Hello World!
>> Computation time for my_fun: 4.00 s
The same for the other method given, i.e. get_execution_time_log
.
[ ] Implement logger level
@2022, Leonardo Alchieri
People-Centered Computing Lab - UniversitĂ della Svizzera italiana, Switzerland