maloja/maloja/proccontrol/profiler.py

15 lines
282 B
Python

import cProfile, pstats
profiler = cProfile.Profile()
def profile(func):
def newfunc(*args,**kwargs):
profiler.enable()
result = func(*args,**kwargs)
profiler.disable()
pstats.Stats(profiler).dump_stats(f"dev/benchmarking/{func}.stats")
return result
return newfunc