def profile(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
profiler = cProfile.Profile()
try:
return profiler.runcall(func, *args, **kwargs)
finally:
stats = pstats.Stats(profiler)
stats.strip_dirs()
stats.sort_stats('tottime')
stats.print_stats()
return wrapper
评论列表
文章目录