【发布时间】:2016-02-05 00:47:23
【问题描述】:
我知道在使用perf stat 的程序执行期间,我可以获得分支错误预测的总百分比。但是如何获取特定分支的统计信息(C 代码中的if 或switch 语句)?
【问题讨论】:
标签: linux profiling perf branch-prediction
我知道在使用perf stat 的程序执行期间,我可以获得分支错误预测的总百分比。但是如何获取特定分支的统计信息(C 代码中的if 或switch 语句)?
【问题讨论】:
标签: linux profiling perf branch-prediction
您可以在branch-misses 事件中取样:
sudo perf record -e branch-misses <yourapp>
然后报告(甚至选择您感兴趣的功能):
sudo perf report -n --symbols=<yourfunction>
在那里,您可以访问带注释的代码并获取给定分支的一些统计信息。或者直接annotate 使用带有--symbol 选项的perf 命令。
【讨论】:
branches 和branch-misses 事件会更有用:sudo perf record -e branches,branch-misses。使用--symbol 将有函数的总计数;在带注释的代码中,当前函数将占总计数的百分比。