So i'm using cProfile and snakeviz to profil my code. My code has decorator which seems to make the cProfile results not very correct :
my code :
import time
import decorator
@decorator.decorator
def my_deco(f, *args, **kwargs):
ret = f(*args, **kwargs)
return ret
def a():
time.sleep(2)
b()
c()
@my_deco
def b():
time.sleep(3)
d()
@my_deco
def c():
time.sleep(1)
d()
@my_deco
def d():
time.sleep(3)
if __name__ == "__main__":
a()
profiling without decorator (expected behavior) : In this case, b, c are at the same level and d bellow.
profiling with decorator (not wanted behavior) : In this case, b, c and d are at the same level.