整理 cProfile 等性能分析工具,用于定位运行时热点与瓶颈。
导航
- 总览:tools
- 相关:tools-code-analysis
- 相关:tools-testing
收录来源
raw/langs/pythons/tools/tune.rstraw/langs/pythons/tools/tunes/cProfile.rst
条目内容
cProfile
- Python内置的分析模块cProfile和profile对于识别代码中存在的性能瓶颈非常有用。它们测量每个函数的执行时间并提供详细的统计信息。
示例:
import cProfile
def my_function():
# 函数代码
# 对该函数进行分析
cProfile.run('my_function()')