oprofile
此工具对性能测试影响比较小,通过时钟中断的方式,分析程序的性能
此工具不需要修改源代码,可以在线上进行数据收集
使用简单流程:
opcontrol --init
opcontrol --setup --event=INST_RETIRED:10000:0:0:1 --separate=library,thread --no-vmlinux
opcontrol --start
./a.out # run program
实时查看a.out的执行状况 opcontrol --dump; opreport -l a.out
opcontrol --shutdown
opcontrol --save=detest #日志存放目录:/var/lib/oprofile/samples/detest
using log file: /var/lib/oprofile/samples/oprofiled.log
opreport -l session:detest --merge tgid > prof.txt
opcontrol --reset # 清除上一次数据:
10) 查看检测结果:
opreport : 以镜像(image)的角度显示检测结果,进程、动态库、内核模块属于镜像范畴
opreport -l : 以函数的角度显示检测结果
opreport -l test : 以函数的角度,针对test进程显示检测结果
opannotate -s test : 以代码的角度,针对test进程显示检测结果
此工具对性能测试影响比较小,通过时钟中断的方式,分析程序的性能
此工具不需要修改源代码,可以在线上进行数据收集
使用简单流程:
opcontrol --init
opcontrol --setup --event=INST_RETIRED:10000:0:0:1 --separate=library,thread --no-vmlinux
opcontrol --start
./a.out # run program
实时查看a.out的执行状况 opcontrol --dump; opreport -l a.out
opcontrol --shutdown
opcontrol --save=detest #日志存放目录:/var/lib/oprofile/samples/detest
using log file: /var/lib/oprofile/samples/oprofiled.log
opreport -l session:detest --merge tgid > prof.txt
opcontrol --reset # 清除上一次数据:
10) 查看检测结果:
opreport : 以镜像(image)的角度显示检测结果,进程、动态库、内核模块属于镜像范畴
opreport -l : 以函数的角度显示检测结果
opreport -l test : 以函数的角度,针对test进程显示检测结果
opannotate -s test : 以代码的角度,针对test进程显示检测结果
opannotate -s /lib64/libc-2.4.so : 以代码的角度,针对libc-2.4.so库显示检测结果
实验结果:1:opreport -l a.out 重定向输出到文件中
2:opannotate -s a.out 重定向输出代码级分析结果到文件中查看
问题:设置采样频率,为最小值6000。