def _run_profiler(function, *args, **kwargs):
"""Run a profiler on the specified function."""
profiler = cProfile.Profile()
profiler.enable()
result = function(*args, **kwargs)
profiler.disable()
stats = pstats.Stats(profiler).sort_stats('cumtime')
stats.print_stats()
return result
评论列表
文章目录