1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00
maloja/maloja/proccontrol/profiler.py

18 lines
317 B
Python
Raw Normal View History

import cProfile, pstats
profiler = cProfile.Profile()
def profile(func):
def newfunc(*args,**kwargs):
profiler.enable()
result = func(*args,**kwargs)
profiler.disable()
2022-03-06 04:58:02 +03:00
try:
pstats.Stats(profiler).dump_stats(f"dev/benchmarking/{func.__name__}.stats")
except:
pass
return result
return newfunc