我想描述一下我的代码.所以我这样做:
valgrind --tool=callgrind my_program [programm arguments]
kcachegrind callgrind.out.x
Run Code Online (Sandbox Code Playgroud)
现在我有这样的kcachegrind窗口:
有很多核心和库函数,但是我如何设置valgrind或kcachegrind仅跟踪函数在我的代码中(当然,它还有调用库函数)?
预期的输出是这样的:
time number of calls function_name()
4,52% 569854 CSim2Sim my_function1(int argc, char* argv[])
3,52% 452158 CSim2Sim my_function2(int argc, char* argv[])
3,52% 36569 CSim2Sim my_function3(int argc, char* argv[])
1,52% 1258 CSim2Sim my_function4(int argc, char* argv[])
Run Code Online (Sandbox Code Playgroud) 有这样的事吗?
我在Windows上并使用WinCacheGrind应用程序,它似乎不适用于大文件(~2 MB).我收到"无法找到呼叫目标"等错误.
你知道用PHP编写的这些文件的任何解析器可以帮助我构建自己的cachegrind分析器吗?
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对象.在这方面的任何帮助都是有用的.
相关信息:
我希望能够看到我的应用程序中的每个线程使用callgrind"昂贵".我使用--separate-thread=yes选项进行了分析,该选项为整个应用程序提供了一个callgrind文件,然后是每个线程一个.
这对于查看任何给定线程的配置文件很有用,但我真正想要的只是每个线程的CPU时间排序列表,因此我可以看到哪些线程是最大的线程.
我已经开始分析一个包含许多sleep(n)语句的脚本.总而言之,我花了超过99%的睡眠时间.尽管如此,它在实际工作期间偶尔遇到性能问题但是相关的,有趣的分析数据在例如使用kcachegrind时变得非常难以识别.
有没有办法可以将某些调用/函数列入黑名单?或者,如何通过对分析数据文件进行后处理来过滤掉这样的调用?
我正在使用profilestats装饰器(http://pypi.python.org/pypi/profilestats).
谢谢
如何在 kcachegrind 中查看 gprof 的输出?这里是从 gcc 的 gmon.out 到 callgrind.out 的转换器吗?
我想分析我的Python程序,以了解为什么它这么慢。我决定使用Yappi(因为我的程序是多线程的),并使用KCacheGrind显示结果。这是我的方法:
# Profile of the update method
def profile_update(table, start, end):
print("Profiling update() on the %s table..." % (table))
yappi.start(builtins=True)
app.update(...)
stats = yappi.get_func_stats()
output_name = "profiler_%s.out." % (table) + datetime.now().isoformat()
stats.save("profilers_outputs/" + output_name, type='callgrind')
yappi.stop()
yappi.clear_stats()
print('\n\n\n')
Run Code Online (Sandbox Code Playgroud)
方法更新用于从数据库中获取数据,其时间范围在开始和结束之间。
输出文件已正确创建,但是当我启动KCacheGrind时,它会输出很多错误,如下所示:
kcachegrind(35484): Loading "profilers_outputs/profiler_benchmark.out.2019-06-26T17:21:41.147461" : 17529 : "Undefined compressed function index 586"
kcachegrind(35484): Loading "profilers_outputs/profiler_benchmark.out.2019-06-26T17:21:41.147461" : 17529 : "Invalid called function, setting to unknown"
Run Code Online (Sandbox Code Playgroud)
最后,我得到了这个调用图,其中所有未识别的函数都被汇总为一个,从而使其变得混乱且完全不相关。有谁知道为什么会这样吗?
我使用这个命令在Centos上安装了valgrind :
yum install valgrind kcachegrind graphviz
Run Code Online (Sandbox Code Playgroud)
然后我使用callgrind工具为我的c ++程序.它生成了callgrind.out.42424文件.
现在,我想使用以下命令在KCacheGrind上打开此文件:
kcachegrind ./callgrind.out.42424
Run Code Online (Sandbox Code Playgroud)
但终端说
bash kcachegrind:找不到命令
我不知道为什么我得到这个错误,而我安装它.我是否需要在特定目录中运行此命令?
我已经开始Kcachegrind用于性能分析.但我不明白GUI和输出图.
例如,此调用图
SignatureIterator::iterate_parameters()我不明白9.25%指的是什么?5 198x意味着多少次SignatureIterator::iterate_parameters()叫 SignatureIterator::parse_type()?100%in是什么意思Symbol::byte_at(int) const?什么是ELF Object?
注意:在官方文档http://kcachegrind.sourceforge.net/html/CallGraph.html中,但仍然不明白是什么the caller distance to the function?
kcachegrind ×10
callgrind ×4
valgrind ×4
profiling ×3
python ×3
c++ ×2
cprofile ×1
gprof ×1
performance ×1
php ×1
profiler ×1
profilestats ×1
python-2.7 ×1
windows ×1
xdebug ×1
yappi ×1