OProfile安装和使用
一、OProfile安装
1、从http://oprofile.sourceforge.net/download/ 下载OProfile的源码
2、sudo ./configure
可能会出现错误,我遇到两个错误,都是缺少依赖库。
1)popt library not found
sudo apt-get install libpopt-dev
2)liberty library not found
sudo apt-get install binutils-dev
然后重新 sudo ./configure --with-kernel-suppot
3、make
4、make install
二、OProfile 使用
1、开始
sudo opcontrol --deinitsudo opcontrol --setup --no-vmlinux sudo opcontrol --initsudo opcontrol --reset sudo opcontrol --start2、运行程序 ./test
3、 sudo opcontrol --dump 将采集的结果写入文件sudo opcontrol --shutdown 关闭
4、sudo opreport -l test 按照函数显示结果sudo opannotate -s test 按照代码显示结果
参考: