标签: yappi

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

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

最后,我得到了这个调用图,其中所有未识别的函数都被汇总为一个,从而使其变得混乱且完全不相关。有谁知道为什么会这样吗?

python profiler kcachegrind yappi

7
推荐指数
0
解决办法
95
查看次数

标签 统计

kcachegrind ×1

profiler ×1

python ×1

yappi ×1