Linuxoprofile命令

王朝学院·作者佚名  2016-08-27  
宽屏版  字体: |||超大  

一、简介

oPRofile是linux平台上的一个功能强大的性能分析工具,支持两种采样(sampling)方式:基于事件的采样(eventbased)和基于时间的采样(timebased),它可以工作在不同的体系结构上,包括MipS、ARM、IA32、IA64和AMD。

二、安装1)打开内核OPROFILE选项,否则运行oProfile将提示:

[root@localhost oprofile-0.9.6]# opcontrol --init

FATAL: Module oprofile not found.

FATAL: Module oprofile not found.

Kernel doesn't support oprofile

2)编辑内核配置文件:.config,将其中的# CONFIG_OPROFILE is not set改为CONFIG_OPROFILE=m(或者y)[root@localhost ~]# cd /usr/src/linux-2.6.37.2[root@localhost linux-2.6.37.2]#vi.config

如下:

CONFIG_PROFILING=y

CONFIG_X86_LOCAL_APIC=y

CONFIG_X86_IO_APIC=y

CONFIG_PCI_IOAPIC=y

3)编译内核并重启机器

http://www.linuxidc.com/Linux/2014-10/108768.htm

4)下载源码,编译安装

wgethttp://cznic.dl.sourceforge.net/project/oprofile/oprofile/oprofile-1.0.0/oprofile-1.0.0.tar.gz

tar-zxvf oprofile-1.0.0.tar.gz

cd oprofile-1.0.0./configuremakemakeinstall

三、工具集

ophelp: 列出所有支持的事件。

opcontrol: 设置需要收集的事件。

opreport: 对结果进行统计输出。

opannaotate:产生带注释的源/汇编文件,源语言级的注释需要编译源文件时的支持。

opstack: 产生调用图profile,但要求x86/2.6的平台,并且linux2.6安装了call-graphpatchopgprof: 产生如gprof相似的结果。

oparchive: 将所有的原始数据文件收集打包,可以到另一台机器上进行分析。

op_import: 将采样的数据库文件从另一种abi转化成本地格式。

四、使用步骤

1)启动检测

modprobeoprofile timer=1opcontrol--no-vmlinux

opcontrol--separate=kernelopcontrol --init

opcontrol--reset

opcontrol –start

2)运行程序

运行测试程序

3)停止检测

opcontrol --dump

opcontrol--stop

opcontrol--shutdown

opcontrol--deinit

4)检测结果

opreport

opreport-l ./test

opannotate--source ./test

五、oprofile实例

1)应用程序性能测试

http://www.cnblogs.com/bangerlee/archive/2012/08/30/2659435.html

2)内核模块性能测试

http://www.oenhan.com/oprofile-cpu-analysis

六、常见问题

1)oprofile抓不到数据

http://blog.csdn.net/cybertan/article/details/8015611

参考:http://blog.chinaunix.net/uid-21768364-id-186057.html

http://www.cnblogs.com/bangerlee/archive/2012/08/30/2659435.html

http://www.oenhan.com/oprofile-cpu-analysis

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有