Android性能专项测试之Batterystats

转载于 http://www.2cto.com/kf/201510/445482.html

Batterystats & Battery Historian Walkthrough
Battery Historian Charts
Android应用的耗电量统计
SupplicantState

batterystats使用条件

5.0以上系统 battery-historian脚本

batterystats的启动

启动统计Battery数据的话,首先要初始化batterystats数据

?
1
2
3
4
5
<code class = "hljs" livecodeserver= "" >adb kill-server
 
> adb devices
 
> adb shell dumpsys batterystats --reset</code>

上面的操作执行完毕后,拔掉手机,操作你的App,操作完成后,重新连接手机,执行下面的命令,收集Battery数据:
adb shell dumpsys batterystats > batterystats.txt
得到这些数据后,这个时候使用我们的battery-historian来生成我们可见HTML报告:
python historian.py batterystats.txt > batterystats.html

得到的报告如下:

这里写图片描述

Battery Historian指标

Android性能专项测试之battery-historian试用 一文中已经介绍了一些属性,但是目前又增加很多,下面来看看新加属性的意义:

属性意义
gpsgps是否开启
sync是否跟后台同步
mobile_radio是否开启radio
wake_reason唤醒原因
phone_in_call进行通话

batterystats信息过滤

Battery History

电量相关数据的时间序列:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<code class = "hljs" lasso= "" >Battery History ( 0 % used, 152 used of 256KB, 5 strings using 256 ):
                     0 ( 9 ) RESET:TIME: 2015 - 10 - 09 - 19 - 50 - 15
                     0 ( 2 ) 009 status=charging health=good plug=usb temp= 324 volt= 3683 +running +wake_lock +wifi_full_lock +audio +screen +plugged data_conn=lte phone_signal_strength=moderate brightness=bright +wifi_running +wifi wifi_signal_strength= 4 wifi_suppl=completed top=u0a34:com.google.android.googlequicksearchbox
                     0 ( 2 ) 009 user= 0 : 0
                     0 ( 2 ) 009 userfg= 0 : 0
                +189ms ( 2 ) 009 volt= 3660
                +216ms ( 2 ) 009 volt= 3688
              +8s387ms ( 2 ) 009 +gps conn= 3 :CONNECTED
              +9s387ms ( 2 ) 009 -top=u0a34:com.google.android.googlequicksearchbox
              +9s387ms ( 2 ) 009 -gps +top=u0a130:com.example.android.sunshine.app
              +9s569ms ( 2 ) 009 +mobile_radio conn= 3 :DISCONNECTED
             +10s217ms ( 2 ) 009 volt= 3577
             +17s294ms ( 2 ) 009 volt= 3619
             +20s216ms ( 2 ) 009 volt= 3576
             +21s530ms ( 1 ) 009 +wifi_scan
             +22s801ms ( 1 ) 009 -wifi_scan
             +29s842ms ( 1 ) 009 -mobile_radio
             +30s252ms ( 2 ) 009 volt= 3616 </code>

Per-PID Stats

每一个进程执行了多长的时间

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<code class = "hljs" livecodeserver= "" >Per-PID Stats:
   PID 0 wake time: +396ms
   PID 868 wake time: +1s682ms
   PID 1402 wake time: +539ms
   PID 0 wake time: +6s473ms
   PID 868 wake time: +3ms
   PID 1723 wake time: +166ms
   PID 4841 wake time: +11m1s479ms
   PID 19942 wake time: +271ms
   PID 868 wake time: +42ms
   PID 21564 wake time: +172ms
   PID 15488 wake time: +67ms
   PID 4841 wake time: +6s512ms
   PID 4841 wake time: +6s512ms
   PID 18217 wake time: +126ms
   PID 3876 wake time: +228ms
   PID 868 wake time: +20s440ms
   PID 16547 wake time: +23ms
   PID 22121 wake time: +288ms
   PID 22146 wake time: +59ms
   PID 16424 wake time: +485ms
</code>

Statistics since last charge

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<code applescript= "" class = "hljs" >Statistics since last charge:
   System starts: 0 , currently on battery: false
   Time on battery: 0ms ( 0.0 %) realtime, 0ms ( 0.0 %) uptime
   Time on battery screen off: 0ms ( 0.0 %) realtime, 0ms ( 0.0 %) uptime
   Total run time: 34s 134ms realtime, 34s 134ms uptime
   Start clock time: 2015 - 10 - 09 - 19 - 50 - 15
   Screen on: 0ms (--%) 0x, Interactive: 0ms (--%)
   Screen brightnesses: (no activity)
   Connectivity changes: 2
   Mobile total received: 0B, sent: 0B (packets received 0 , sent 0 )
   Phone signal levels: (no activity)
   Signal scanning time: 0ms
   Radio types: (no activity)
   Mobile radio active time: 0ms (--%) 0x
   Mobile radio active adjusted time: 0ms (--%)
   Wi-Fi total received: 0B, sent: 0B (packets received 0 , sent 0 )
   Wifi on: 0ms (--%), Wifi running: 0ms (--%)
   Wifi states: (no activity)
   Wifi supplicant states: (no activity)
   Wifi signal levels: (no activity)
   Bluetooth on: 0ms (--%)
   Bluetooth states: (no activity)
 
</code>

Estimated power use (mAh)

目前只能算比较粗略的估计,不能作为实际消耗数据,其他google更为精准的数据

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<code class = "hljs" rust= "" >  Estimated power use (mAh):
     Capacity: 3220 , Computed drain: - 2444.11370879 , actual drain: 0.00000000
     Idle: 24.7
     Uid u0a46: - 0.01197222
     Uid u0a100: - 0.04600000
     Uid u0a29: - 0.07444444
     Uid u0a118: - 0.14044444
     Uid u0a104: - 0.73288889
     Uid 1000 : - 2.12172492
     Uid u0a14: - 3.36807500
     Uid u0a99: - 3.78076692
     Phone calls: - 19.54370833
     Cell standby: - 107.36537361
     Screen: - 2331.64616000 </code>

Per-app mobile ms per packet

radio唤醒时间除以数据包发送次数,该时间越小代表性能越好,一个高效的App会将所有的流量转化为batches。

All partial wake locks

所有程序中wakelock,关注持续时间和数量

 


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值