我正在使用 hotshot 来分析我的 Python 程序,有没有办法聚合配置文件并在 Kcachegrind 中查看总结果?
经过一些研究,我使用 pstats 以下面给出的方式聚合配置文件pyprof2calltree
并将结果转换为 kcachegrind 格式
>>> pf = pstats.Stats("profile1.prof")
>>> p2 = pf.add("profile2.prof")
>>> p2.dump_stats("aggregated.prof")
pyprof2calltree
给了我这样的错误。
File "/usr/local/bin/pyprof2calltree", line 9, in <module>
load_entry_point('pyprof2calltree==1.1.0', 'console_scripts', 'pyprof2calltree')()
File "/usr/local/lib/python2.7/dist-packages/pyprof2calltree.py", line 240, in main
kg.output(file(outfile, 'wb'))
File "/usr/local/lib/python2.7/dist-packages/pyprof2calltree.py", line 106, in output
self._entry(entry)
File "/usr/local/lib/python2.7/dist-packages/pyprof2calltree.py", line 167, in _entry
self._subentry(lineno, subentry, call_info)
File "/usr/local/lib/python2.7/dist-packages/pyprof2calltree.py", line 178, in _subentry
print >> out_file, 'calls=%d %d' % (call_info[0], co_firstlineno)
TypeError: 'int' object is not subscriptable
我在这里做错了什么还是有其他方法可以做到这一点?