【发布时间】:2015-09-14 13:31:27
【问题描述】:
我正在开发一个使用 GPS 和网络位置信息跟踪用户移动的应用程序。我使用服务、活动识别、不同的采样率和 gps/网络超时来提高电池效率。
问题是如何测量我的应用程序消耗的准确数量(mV、mA/小时或总消耗的百分比)?不仅基于CPU使用率,还通过调用GPS、网络、WiFi。所以我可以对应用的电池效率做出一个结论。
我正在通过adb shell dumpsys batterystats 获取电池统计信息。
这是我在步行和火车旅行期间使用 1 小时时看到的:
Mobile network: 10.61KB received, 7.41KB sent (packets 26 received, 34 sent)
Mobile radio active: 18s 180ms (0.7%) 8x @ 303 mspp
Wifi Running: 0ms (0.0%)
Full Wifi Lock: 2m 8s 907ms (3.9%)
**Wifi Scan: 3m 20s 904ms (6.1%)**
Wake lock NlpCollectorWakeLock: 1m 23s 525ms partial (100 times) realtime
Wake lock *alarm*: 269ms partial (97 times) realtime
Wake lock NlpWakeLock: 264ms partial (83 times) realtime
Wake lock LocationManagerService: 64ms partial (19 times) realtime
TOTAL wake: 1m 24s 122ms partial realtime
**Sensor GPS: 5m 15s 109ms realtime (185 times)**
Foreground activities: 2m 40s 107ms realtime (10 times)
Foreground for: 51m 51s 176ms
Active for: 55m 1s 142ms
Proc xxxxxxxxxxx:
**CPU: 30s 670ms usr + 6s 800ms krn ; 7s 810ms fg**
Proc *wakelock*:
**CPU: 12s 660ms usr + 15s 40ms krn ; 0ms fg**
Apk xxxxxxxxxxx:
122 wakeup alarms
Service xxxxxxxxxxx.ActivityRecognitionIntentService:
Created for: 6s 652ms uptime
Starts: 356, launches: 356
Apk com.google.android.gms:
(nothing executed)
我猜最耗电的是 Sensor GPS 调用、CPU 使用率和 Wifi。
问题:
1) 我该如何解释这些数字?是否有可能找出每个 GPS 呼叫(或实时)的耗电量?
2) 有没有更好的方法来找出 App 的总耗电量?
【问题讨论】:
-
我还可以看到“应用程序的估计耗电量 (mAh):16.4 mAh”。 (2300 是 100% => 16.4 是 0.71%),这肯定不是总功耗。
标签: android performance gps adb battery