gpt4 book ai didi

python - 使用qcachegrind处理profilestats输出时如何源注释python

转载 作者:太空狗 更新时间:2023-10-29 20:31:23 25 4
gpt4 key购买 nike

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)'

使用选项

Settings -> Configure -> Source Annotation 

并且添加源基目录没有用。

我有一种感觉,该实用程序需要一个与 Python 无关的 ELF 对象。在这方面的任何帮助都是有用的。

相关信息:

  • Python 2.7
  • 个人资料统计 (2.0)
  • QCachegrind 0.7.4
  • Windows 2012R2

最佳答案

我支持@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 通过自制软件安装在 OSX 10.11 上

关于python - 使用qcachegrind处理profilestats输出时如何源注释python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31109412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com