首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android 移栽oprofil性能监测工具

2013-09-12 
Android 移植oprofil性能监测工具关于oprofile的移植,在Ubuntu Server 10.04平台上交叉编译,移植到Android

Android 移植oprofil性能监测工具
关于oprofile的移植,在Ubuntu Server 10.04平台上交叉编译,移植到Android,经过实践,以下是交叉编译的正确步骤,不保证在其他环境中能正确运行,以下是编译环境:
build: Ubuntu Server 10.04host: Android-2.2r2cross compiler: mips-linux-gnu-gcc  version:4.3.2cpu: mips
交叉编译oprofile,依赖(popt,binutils);
1.Download Open Source:
popt-1.14.tar.gzbinutils-2.21.tar.gzoprofile-0.9.6.tar.gz

2.Building environment
重要:touch env.shvi env.sh内容如下:export PATH=/home/gzshun/share/mips-4.3/bin:$PATH  ##修改为自己的工具链路径export CC="mips-linux-gnu-gcc -EL"export CXX="mips-linux-gnu-g++ -EL"export CFLAGS=-staticexport CXXFLAGS=-staticexport CPPFLAGS=-static
source env.sh
3.Building popt-1.14.tar.gz
tar zxvf popt-1.14.tar.gzcd popt-1.14ac_cv_va_copy=yes ./configure --with-kernel-support --host=mips-linux-gnu --prefix=/home/gzshun/poptmakemake install
以下是静态编译:4.Building binutils-2.21.tar.gz
tar zxvf binutils-2.21.tar.gzcd binutils-2.21./configure --with-kernel-support --host=mips-linux-gnu --prefix=/home/gzshun/binutils --enable-sharedmake configure-hostmake LDFLAGS="-all-static"make install

5.Building oprofile-0.9.6.tar.gz
tar zxvf oprofile-0.9.6.tar.gzcd oprofile-0.9.6./configure --with-kernel-support --host=mips-linux-gnu --prefix=/home/gzshun/oprofile/ --with-extra-libs=/home/gzshun/popt/lib/ --with-extra-includes=/home/gzshun/popt/include/ --with-binutils=/home/gzshun/binutilsmake LDFLAGS="-all-static -L/home/gzshun/binutils/lib -Xlinker -R -Xlinker /home/gzshun/binutils/lib  -L/home/gzshun/popt/lib/"make install

6.添加内核oprofile模块General setup  --->[*] Profiling support (EXPERIMENTAL)<*> OProfile system profiling (EXPERIMENTAL)将oprofile模块编进内核,也可以编程模块
开发板性能测试篇:
1.注意a.在ubuntu编译oprofile的生成路径是:/home/gzshun/oprofile,所以在开发板也需要建立相应的路径mkdir -p /home/gzshun/将生成的oprofile目录拷贝到开发板/home/gzshun/目录下##原因:在ubuntu环境下编译,oprofile会按照原本在ubuntu的路径寻找需要的lib库。(生成目录自己定)b.修改oprofile/bin/opcontrol第1968行,将/usr/bin修改为/binc.在Android系统中的/etc目录下新建mtab文件,并添加内容:nodev /dev/oprofile oprofilefs rw 0 0d.在开发板设置oprofile的环境变量,必须放在PATH的前面,因为原Android系统也存在2个命令。
e.oprofile生成报告的默认地址是:/var/lib/oprofile
2.性能测试##Android没有内核,所以需要从虚拟地址去引用vmlinuxgrep "_stext" /proc/kallsyms  --> result: 84000400 T _stext  ##获取vmlinux虚拟的起始地址grep "_etext" /proc/kallsyms  --> result: 84342a18 A _etext  ##获取vmlinux虚拟的结束地址opcontrol --init  --> 提示错误,挂载oprofilefs即可mount -t oprofilefs nodev /dev/oprofile  ##挂载oprofile需要的设备信息opcontrol --init   ##初始化opcontrol --reset  ##清空上次保留下来的信息echo 0 > /data/vmlinux ##生成一个虚拟的vmlinuxopcontrol --callgraph=2 --vmlinux=/data/vmlinux --kernel-range=0x84000400,0x84342a18 ##起始地址,结束地址, 跟踪内核或者 opcontrol --setup --callgraph=2 --no-vmlinux ##不跟踪 内核opcontrol --setup --event=CYCLES:7500:0:0:1  ##事件采样opcontrol --start  ##开始测试性能opcontrol --status ##查看状态.....等待时间,测试opcontrol --dump  ##将测试性能信息写入磁盘。opreport  ##打印报告opcontrol --stop ##停止检测opcontrol --shutdown  ##关闭检测守护进程opcontrol --deinit  ##卸载oprofile内核模块
opreport出来的一个例子:
分析:Samples 采样到的次数% 占的百分比Symbol name 函数名
Android@localhost:/# opreportOverflow stats not availableCPU: MIPS 24K, speed 0 MHz (estimated)Counted CYCLES events (Cycles) with a unit mask of 0x00 (No unit mask) count 7500CYCLES:7500samples|      %------------------132594 18.2787 opreport103155 14.2204 libdvm.so96514 13.3049 libc.so88463 12.1950 libskia.so79213 10.9199 app_processCYCLES:7500samples|      %------------------79213 100.000 [heap] (tgid:1444 range:0x83000-0x401000)77023 10.6180 oprofiled57865  7.9770 libcutils.so19547  2.6946 busybox17571  2.4222 libwebcore.so13223  1.8229 libplayback.so9490  1.3082 libdisplay.so3906  0.5385 libbinder.so3816  0.5261 libutils.so3374  0.4651 ophelp3373  0.4650 libandroid_runtime.so2069  0.2852 libcore.so1816  0.2503 libz.so1648  0.2272 libsqlite.so1342  0.1850 dalvik-jit-code-cache (deleted)1141  0.1573 vmlinux1110  0.1530 libui.so975  0.1344 libsurfaceflinger.so840  0.1158 libGLES_android.so711  0.0980 libhw.so604  0.0833 example_display591  0.0815 libpixelflinger.so528  0.0728 libsurfaceflinger_client.so522  0.0720 linker494  0.0681 libicuuc.so467  0.0644 libdcchd_android.so293  0.0404 libnativehelper.so169  0.0233 libm.so158  0.0218 uinput132  0.0182 gralloc.smp86xx.so117  0.0161 libicui18n.so98  0.0135 copybit.smp86xx.so75  0.0103 libstdc++.so58  0.0080 libEGL.so58  0.0080 libhardware.so57  0.0079 libGLESv1_CM.so46  0.0063 librmlibplay_default_plugin.so35  0.0048 opjitconv32  0.0044 libandroid_servers.so22  0.0030 libhardware_legacy.so15  0.0021 liblog.so11  0.0015 servicemanager10  0.0014 libmedia.so9  0.0012 adbd8  0.0011 logwrapper5 6.9e-04 libmediaplayerservice.so4 5.5e-04 libmedia_jni.so3 4.1e-04 libsysutils.so1 1.4e-04 init1 1.4e-04 libemoji.so
本文出自 “清源教育” 博客,转载请注明此处,谢谢!

热点排行