1. 首页
  2. 数据库
  3. 其它
  4. 说说如何使用 Python 的 cProfile 模块分析代码性能

说说如何使用 Python 的 cProfile 模块分析代码性能

上传者: 2020-12-30 05:48:20上传 PDF文件 50.8KB 热度 18次
cProfile 模块是自 python 2.5 以来标准版 Python 解释器的默认性能分析器。它是一种确定性分析器,只测量 CPU 时间,并不包含内存消耗和其他与内存相关联的信息。 代码分析模板如下: import cProfile, pstats, io from pstats import SortKey pr = cProfile.Profile() pr.enable() # ... do something ... pr.disable() s = io.StringIO() sortby = SortKey.CUMULATIVE ps = pstats.St
下载地址
用户评论