Abh*_*jit 9 python profiling kcachegrind python-2.7 profilestats
Kcachegrind是一个很棒的实用工具,可以在分析代码时直观地表示源代码级别的热点.在微优化我的C++代码库时,我发现它非常有用.对于我最新的python项目,我开始使用Kcachegrind处理profilestats的输出.Kcachegrind是一个仅限Linux的实用程序,但是各种非官方端口都可用,我使用的是qcachegrind.通常它在很大程度上起作用并且对于大多数问题都是足够的,除了我很难获得源注释工作.
在源标签上,我正在接受熟悉的源缺失消息
There is no source available for the following function:
'main C:\Projects\module\src\source.py:397'
This is because no debug information is present
Recompile source and redo the profile run.
The function is located in the ELF Object:
'(unknown)'
Run Code Online (Sandbox Code Playgroud)
使用选项
Settings -> Configure -> Source Annotation
Run Code Online (Sandbox Code Playgroud)
并添加源基目录无用.
我有一种感觉,该实用程序需要一个与Python无关的ELF对象.在这方面的任何帮助都是有用的.
相关信息:
我第二次@taleniat 评论。我是 OSX 用户。我在让 qcachegrind 工作时遇到了一些麻烦,所以我最终使用了 pyprof2calltree,它工作得很好,包括源代码选项卡。YMMV。
首先使用 cProfile 运行脚本
python -m cProfile -o report.profile report.py
然后您可以使用 pyprof2calltree 启动 qcachegrind (无需中间转换)。
pyprof2calltree -k -i report.profile
顺便说一句,Python 2.7.10 和 qcachegrind 0.7.4 通过 Homebrew 在 OSX 10.11 上安装