使用Batterystats測試電量

Batterystats collects battery data from your device.

Batterystats is part of the Android framework.

Prerequisites:

A mobile device with Developer Options enabled running Android 5.0 or higher.

(前提條件:一臺Android5.0及以上系統(tǒng)的手機,并開啟開發(fā)者選項,打開USB調(diào)試)

1、Download the open-source Battery Historion Python script from GitHub (https://github.com/google/battery-historian).

2、Unzip the file to extract the Battery Historian folder. Inside the folder, find the historian.py file and move it to the Desktop or another writable directory.

3、Connect your mobile device to your computer.

4、On your computer, open a Terminal window.

5、Change to the directory where you've saved historian.py,

for example: cd ~/Desktop

6、Shut down your running adb server.

> adb kill-server

7、Restart adb and check for connected devices.

> adb devices

注意,默認(rèn)情況下wake數(shù)據(jù)不會被采集,為了更好的分析數(shù)據(jù),需要啟用。

> adb shell dumpsys batterystats --enable full-wake-history

8、Reset battery data gathering.

> adb shell dumpsys batterystats --reset

Resetting erases old battery collection data; otherewise, the output will be huge.

9、Disconnect your device from your computer so that you are only drawing current from the device's battery.

拔出USB,非常重要!因為一直插著USB,當(dāng)電充滿,數(shù)據(jù)會被清空。Batterystats只會記錄最后一次充滿電后的記錄。因此建議先把電充滿,完成以上操作后,拔出USB。

10、Play with your app for a short time.

操作要統(tǒng)計電量的應(yīng)用,所有應(yīng)用都會被統(tǒng)計。因此,也可以統(tǒng)計競品的耗電情況。

11、Reconnect your phone.

12、Make sure your phone is recognized: > adb devices

13、Dump all battery data. This can take a while:

> adb shell dumpsys batterystats > batterystats.txt

batterystats.txt里記載了整臺手機的耗電信息

注意,最后要關(guān)閉全量記錄喚醒,因為保持開啟會造成性能問題。

> adb shell dumpsys batterystats --disable full-wake-history

14、Create a HTML version of the data dump for Battery Historian:

> python historian.py batterystats.txt > batterystats.html

15、Open the batterystats.html file in your browser.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容