Python profiling
from line_profiler import LineProfiler
import time
profiler = LineProfiler()
def profile(func):
def inner(*args, **kwargs):
profiler.add_function(func)
profiler.enable_by_count()
return func(*args, **kwargs)
return inner
@profile
def a():
b=1
for i in range(2):
b+=i
time.sleep(1)
return b
print(a())
profiler.print_stats()