现在的位置: 首页 > 综合 > 正文

Android系统分析工具(一) Oprofile

2013年10月13日 ⁄ 综合 ⁄ 共 1780字 ⁄ 字号 评论关闭

Oprofile 是用于Linux 性能分析工具之一

源代码在 http://oprofile.sourceforge.net , 也有一些使用的文档

Oprofile可以用来分析android的系统性能,它离不开内核的支持,在配置linux内核的时候在CPU PMU的配置里要把Profiling support和OProfile system profiling选上。

Oprofile 命令子集:

         op_help: 帮助

         opcontrol: 控制

         oprofpp: 检索

         op_time: 时间

         op_to_source: 产生源文件

        op_merge: 合并采样文件

        op_import: 导入abi等其它采样数据

         opreport: 报告结果

opcontrol的使用

opcontrol: usage:
   --list-events    list event types
   --help           this message
   --verbose        show extra status
   --setup          setup directories
   --quick          setup and select CPU_CYCLES:150000
   --timer          timer-based profiling
   --status         show configuration
   --start          start data collection
   --stop           stop data collection
   --reset          clears out data from current session
   --shutdown       kill the oprofile daeman
   --callgraph=depth callgraph depth
   --event=eventspec
      Choose an event. May be specified multiple times.
      eventspec is in the form of name[:count], where :
        name:  event name, see "opcontrol --list-events"
        count: reset counter value
   --vmlinux=file   vmlinux kernel image
   --kernel-range=start,end
                    kernel range vma address in hexadecimal

在Android上执行如下命令

rm -R /data/oprofile

 echo 0>/data/vmlinux #用于产生一个假的vmlinux镜像

          # grep " _text" /proc/kallsyms

          c002e000 T _text 

         # grep " _etext" /proc/kallsyms 

          c04a1000A _etext

 

export PATH=/data/bin/oprofile:$PATH
mkdir -p /data/bin/oprofile
busybox --install -s /data/bin/oprofile
rm -rf /var/lib/oprofile/
echo 'nodev /dev/oprofile oprofilefs rw 0 0' > /etc/mtab
insmod /data/bin/oprofile/oprofile.ko
mkdir -p /dev/oprofile
mount -t oprofilefs nodev /dev/oprofile

opcontrol --init
opcontrol --vmlinux=$1 --kernel-range=0x$(grep " _text" /proc/kallsyms|cut -d' ' -f1),0x$(grep " _etext" /proc/kallsyms|cut -d' ' -f1)
opcontrol --event=CPU_CYCLES:10000:0:1:1
opcontrol --start
opcontrol --dump

抱歉!评论已关闭.