gprof是如何工作的? [英] How exactly does gprof work?

查看:73
本文介绍了gprof是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个a肿的问题,所以我提前致歉.我很好奇 gprof 在较低的技术水平上如何工作.我知道它是由计时器完成的,但是为什么需要对可执行文件进行特殊编译才能进行概要分析?编译是否会为统计信息分配空间?

This is something of a bloated question, so I apologize ahead of time. I'm curious about how gprof works on a low technical level. I understand it's done by timers, but then why does the executable need to be specially compiled to be profiled? Does the compilation cause space to be allocated for statistics?

此外,计时如何精确完成?

Also, how is the timing done exactly?

推荐答案

好吧,这给出了统计分析

Well, this gives a good explanation. Also this explains statistical profiling

基本上,gprof会更改程序的可执行文件(称为插入代码),以存储一些簿记信息,例如一个函数被调用多少次.

Essentially gprof will change the executable of your program (this is called instrumenting the code) to store some book-keeping information, e.g. how many times a function is called.

统计分析位来自定期窥探程序计数器,以获取代码执行情况的样本.

The statistical profiling bit comes from snooping the program counter regularly to get a sample of what your code is doing.

Gprof两者都做.它检测代码并通过查看程序计数器来收集样本.

Gprof does both. It instruments the code and collects samples from looking at the program counter.

这篇关于gprof是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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