自动装配循环级分析

发布于 2024-10-10 02:57:40 字数 671 浏览 0 评论 0原文

有谁知道任何汇编循环级分析器?

我一直在使用 gprof,但 gprof 隐藏了循环,它是函数级别的分析,但为了优化我的代码,我想要一些东西进入循环级别。我希望它是自动化的,只给我像 gprof 一样的输出。有人建议我去 dtrace,但我不知道要开始。无论如何,任何人都可以指导我吗? 例如

main:

pushl   %ebp     
movl    %esp, %ebp     
subl    $16, %esp     
movl    $5000000, -4(%ebp)     
movl    $0, -12(%ebp)     
movl    $0, -8(%ebp)    
jmp .L2 

.L3:   

 movl    -8(%ebp), %eax    
 addl    %eax, -12(%ebp)    
 addl    $1, -8(%ebp) 

.L2:    

movl    -8(%ebp), %eax    
cmpl    -4(%ebp), %eax    
jl  .L3     
movl    $0, %eax    
leave     ret 

,在 gprof 中,它会说 main 执行了 1 次,而 foo 执行了 100 次。但我想知道 L2 或 L3 是否执行了 100 万次,那么我的优化重点就在这里。 如果我的问题含糊不清,请让我解释更多 谢谢

Does anyone know any assembly loop level profiler?

I have been using gprof but gprof hides loops and it is function level profiling, yet to optimize my code i want something to go to the loop level. I want it to be automated and just give me the output like gprof. I was recommended to go to dtrace yet I have no idea were to start. anyone can direct me in anyway?
for example

main:

pushl   %ebp     
movl    %esp, %ebp     
subl    $16, %esp     
movl    $5000000, -4(%ebp)     
movl    $0, -12(%ebp)     
movl    $0, -8(%ebp)    
jmp .L2 

.L3:   

 movl    -8(%ebp), %eax    
 addl    %eax, -12(%ebp)    
 addl    $1, -8(%ebp) 

.L2:    

movl    -8(%ebp), %eax    
cmpl    -4(%ebp), %eax    
jl  .L3     
movl    $0, %eax    
leave     ret 

for example in gprof it would say main executed 1 time and foo executed 100 times. yet I want to know if L2, or L3 executed 1M times then my concentration on optimizing would be here.
if my question is vague please ask me to explain more
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

多像笑话 2024-10-17 02:57:40

这取决于您使用的操作系统,但对于这种类型的分析,您通常希望使用采样分析器而不是仪表化分析器,例如

It depends on what OS you are using, but for this kind of profiling you generally want to use a sampling profiler rather than an instrumented profiler, e.g.

浊酒尽余欢 2024-10-17 02:57:40

我建议使用 Callgrind(Valgrind 工具之一,通常与其一起安装)。这可以收集更细粒度的统计信息,kcachegrind 工具非常有用适合可视化结果。

I suggest using Callgrind (one of the Valgrind tools, and usually installed with it). This can gather statistics on a much more fine-grained level, and the kcachegrind tool is very good for visualising the results.

糖粟与秋泊 2024-10-17 02:57:40

如果您使用的是 Linux,Zoom 是一个不错的选择。

如果您使用的是 Windows,LTProf 可能能够做到这一点。

在任何平台上,低技术方法 随机暂停是可以信赖的。

不要寻找指令被执行了多少次。大部分时间都在寻找程序计数器的位置。 (它们不是同一件事。)这将告诉您将优化工作集中在哪里。

If you're on Linux, Zoom is an excellent choice.

If you're on Windows, LTProf might be able to do it.

On any platform, the low-tech method random-pausing can be relied on.

Don't look for how many times instructions are executed. Look for where the program counter is found a large fraction of the time. (They're not the same thing.) That will tell you where to concentrate your optimization efforts.

岁月静好 2024-10-17 02:57:40

KCachegrind 提供每行源代码的分析信息(请参阅此屏幕截图),其中包括CPU 时间、缓存未命中等等...它多次拯救了我的日子。

然而,在探查器内运行代码非常慢(比本机慢几十倍)。

KCachegrind gives profiling information for each line of source code (see this screenshot), and this includes CPU time, cache misses, etc... It saved my day a couple of times.

However running the code inside the profiler is extremely slow (tens of times slower than native).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文