Android系统分析工具(一) Oprofile

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值