python-3.x - 如何解释 python cProfile 输出
问题描述
我在我的 python 脚本上运行 cProfile 以查看我可以在哪里提高性能并使用snakeviz 进行可视化。然而,结果相当模糊;我如何解释它们?这是它的前几行:
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
242059 0.626 0.000 0.914 0.000 pulp.py:585(__init__)
1 0.413 0.413 0.413 0.413 {built-in method _winapi.WaitForSingleObject}
343978/302 0.293 0.000 0.557 0.002 pulp.py:750(addInPlace)
4159617 0.288 0.000 0.288 0.000 pulp.py:165(__hash__)
112 0.282 0.003 0.282 0.003 {method 'read' of '_ssl._SSLSocket' objects}
1913398 0.172 0.000 0.245 0.000 {built-in method builtins.isinstance}
1 0.171 0.171 0.185 0.185 Betfair_Run_Sheet.pyx:243(betfairFinalArray)
377866 0.168 0.000 0.293 0.000 pulp.py:637(addterm)
2255 0.161 0.000 0.161 0.000 mps_lp.py:249(<listcomp>)
1 0.148 0.148 0.570 0.570 mps_lp.py:174(writeMPS)
117214 0.139 0.000 0.444 0.000 pulp.py:820(__mul__)
2 0.136 0.068 0.196 0.098 pulp.py:1465(variablesDict)
5 0.135 0.027 0.135 0.027 {method 'do_handshake' of '_ssl._SSLSocket' objects}
427 0.111 0.000 0.129 0.000 <frozen importlib._bootstrap_external>:914(get_data)
71 0.108 0.002 0.108 0.002 {built-in method _imp.create_dynamic}
2093 0.102 0.000 0.102 0.000 {built-in method nt.stat}
我正在使用 Pulp,所以我知道这会占用大部分时间,但是从上面看设置的细节并不清楚,例如,对于输出的第一行,它似乎暗指我脚本中的第 585 行,但那是根本不是我在其中调用或设置 PULP 部分的地方。
与第<listcomp>
9 个相同,我的脚本的那一行没有列表理解。
像我这样的其他事情{method 'do_handshake' of '_ssl._SSLSocket' objects}
不知道它们是什么意思。
解决方案
推荐阅读
- android - gradle 文件配置以 android API 22 为目标
- android - android - 所有设备都支持哪种 MediaRecorder 配置?
- javascript - Angular:ControlValueAccessor 更新到共享相同 formControlName 的所有组件
- mysql - 使用sql按组计算百分比
- vb.net - 在 tabPage 控件中动态垂直滚动
- python - 将 numpy 数组的行划分为存储桶
- javascript - 引诱报告随着时间的推移而增长并需要更长的时间来生成
- highcharts - 使用 Highcharts API 在散点图中设置背景文本
- php - 运行长 php 脚本的最佳实践
- c# - 为什么在构建解决方案时,从 C# 类库项目中对 C/C++ DLL 项目的引用会在 Visual Studio 中中断?