问题描述
我知道在使用perf stat
执行程序期间,我可以获得分支错误预测的总百分比.但是,如何获取特定分支的统计信息(C代码中的if
或switch
语句)?
I know that I can get the total percentage of branch mispredictions during the execution of a program with perf stat
. But how can I get the statistics for a specific branch (if
or switch
statement in C code)?
推荐答案
您可以在branch-misses
事件上进行采样:
You can sample on the branch-misses
event:
sudo perf record -e branch-misses <yourapp>
然后报告它(甚至选择您感兴趣的功能):
and then report it (and even selecting the function you're interested in):
sudo perf report -n --symbols=<yourfunction>
您可以在其中访问带注释的代码,并获取给定分支的一些统计信息.或使用带有--symbol
选项的perf命令直接annotate
.
There you can access the annotated code and get some statistics for a given branch. Or directly annotate
it with the perf command with --symbol
option.
这篇关于如何衡量Linux上单个分支的错误预测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!