如何衡量Linux上单个分支的错误预测? [英] How to measure mispredictions for a single branch on Linux?

查看:107
本文介绍了如何衡量Linux上单个分支的错误预测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在使用perf stat执行程序期间,我可以获得分支错误预测的总百分比.但是,如何获取特定分支的统计信息(C代码中的ifswitch语句)?

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上单个分支的错误预测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆