Python 分析:KCacheGrind + Yappi 不断显示未知函数

问题描述 投票:0回答:1

我想分析我的 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')

update方法用于从数据库中获取时间范围在start和end之间的数据。

输出文件已正确创建,但是当我启动 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"

我最终得到了这个call graph,其中所有未识别的功能都聚合为一个,使其变得混乱且完全不相关。有谁知道为什么会这样?

python profiler kcachegrind yappi
1个回答
0
投票

更新此问题现已在 Yappi 中得到解决。看看这个 github pull requestissue

© www.soinside.com 2019 - 2024. All rights reserved.