我开发了一个Android应用程序,我想知道我的应用程序在Android设备上的耗电量。我在Stack Overflow上遇到了各种各样的线程,但没有一个帮助过我。
在Android中是否有任何应用程序测量我的应用程序的功耗或任何其他可行的方法?
来自this Stack Overflow post的答案:
我使用了#34; Battery Historian"并生成了batteryinfo.txt和batteryinfo.html
Batteryinfo.txt如下
file.write(perm1 + '\n')
当我打开Batteryinfo.html时,它显示" 找不到结束时间"。
我按照下面的帖子中的答案,并注释了所提到的代码
Battery historian cannot find end time android
这次当我运行命令从batteryinfo.html生成batteryinfo.html时,它显示一个错误(参考注释掉的3行代码)。
注意:由于我的设备不支持使用batterystats,因此使用的是batteryinfo。
我想打开Battery History:
-3m04s883ms 090 6c120104 status=discharging health=overheat plug=none temp=0 volt=3797 +screen +phone_scanning +wifi +wifi_running +wake_lock +sensor brightness=bright phone_state=out
-3m02s651ms 090 6c1a0104 status=charging plug=usb volt=4123 +plugged
-3m00s087ms 090 6c1a0104 volt=4090
-2m57s951ms 090 6c1a0104 volt=4125
-2m43s775ms 090 6c1a0104 volt=4123
-2m41s563ms 087 6c1a0104
-2m31s787ms 087 6c1a0104 volt=4114
-2m28s300ms 087 6c1a0104 volt=4112
-2m26s037ms 087 6c1a0104 volt=4114
-2m22s891ms 087 6c1a0104 volt=4112
-2m20s797ms 087 6c1a0104 volt=4134
-2m08s632ms 087 6c1a0104 volt=3849
-2m06s567ms 083 6c1a0104 volt=3838
-2m04s370ms 083 6c1a0104 volt=4123
-1m43s700ms 087 6c1a0104 volt=4122
-1m32s936ms 087 6c1a0104 volt=4007
-1m22s724ms 083 6c1a0104 health=good
-1m02s524ms 080 6c1a0104 volt=3957
Per-PID Stats:
PID 166 wake time: +203ms
PID 109 wake time: +2m57s295ms
Statistics since last charge:
System starts: 0, currently on battery: false
Time on battery: 2s 232ms (0.0%) realtime, 2s 232ms (0.0%) uptime
Total run time: 3d 15h 52m 45s 402ms realtime, 1d 9h 16m 33s 630ms uptime,
Screen on: 2s 231ms (100.0%), Input events: 0, Active phone call: 0ms (0.0%)
Screen brightnesses: bright 2s 231ms (100.0%)
Kernel Wake lock "PowerManagerService": 2s 191ms (0 times) realtime
Kernel Wake lock "power-supply": 412ms (1 times) realtime
Kernel Wake lock "main": 2s 191ms (0 times) realtime
Total received: 0B, Total sent: 0B
Total full wakelock time: 2s 197ms , Total partial waklock time: 2s 203ms
Signal levels: none 2s 231ms (100.0%) 0x
Signal scanning time: 2s 231ms
Radio types: none 2s 231ms (100.0%) 0x
Radio data uptime when unplugged: 0 ms
Wifi on: 2s 231ms (100.0%), Wifi running: 2s 231ms (100.0%), Bluetooth on: 0ms (0.0%)
Device battery use since last full charge
Amount discharged (lower bound): 0
Amount discharged (upper bound): 0
Amount discharged while screen on: 0
Amount discharged while screen off: 0
#1000:
User activity: 2 other
Sensor 2: 2s 206ms realtime (0 times)
#1013:
Wake lock AudioIn_369: 2s 203ms partial (1 times) realtime
#10010:
Apk com.android.providers.media:
Service com.android.providers.media.MtpService:
Created for: 0ms uptime
Starts: 1, launches: 1
#10029:
Wake lock Samsung Recognition Service: 2s 197ms full (0 times) realtime
Statistics since last unplugged:
Time on battery: 2s 232ms (1.2%) realtime, 2s 232ms (1.2%) uptime
Total run time: 3m 4s 912ms realtime, 3m 4s 911ms uptime,
Screen on: 2s 232ms (100.0%), Input events: 0, Active phone call: 0ms (0.0%)
Screen brightnesses: bright 2s 232ms (100.0%)
Kernel Wake lock "PowerManagerService": 2s 191ms (0 times) realtime
Kernel Wake lock "power-supply": 412ms (1 times) realtime
Kernel Wake lock "main": 2s 191ms (0 times) realtime
Total received: 0B, Total sent: 0B
Total full wakelock time: 2s 232ms , Total partial waklock time: 2s 232ms
Signal levels: none 2s 232ms (100.0%) 0x
Signal scanning time: 2s 232ms
Radio types: none 2s 232ms (100.0%) 0x
Radio data uptime when unplugged: 0 ms
Wifi on: 2s 232ms (100.0%), Wifi running: 2s 232ms (100.0%), Bluetooth on: 0ms (0.0%)
Device is currently plugged into power
Last discharge cycle start level: 90
Last discharge cycle end level: 90
Amount discharged while screen on: 0
Amount discharged while screen off: 0
#1000:
User activity: 2 other
Sensor 2: 2s 232ms realtime (0 times)
#1013:
Wake lock AudioIn_369: 2s 232ms partial (1 times) realtime
#10010:
Apk com.android.providers.media:
Service com.android.providers.media.MtpService:
Created for: 0ms uptime
Starts: 1, launches: 1
#10029:
Wake lock Samsung Recognition Service: 2s 232ms full (0 times) realtime
的详细信息。
答案 0 :(得分:1)
我不知道你的意思是不能读取设置中的估计值。
在Android App power consumption
中查看我的答案" 首先,Google Play的powertutor已经过时了。我检查了它的源代码,发现功耗估算模型适用于某些旧的移动模型。电源导师的价值小于实际功耗。
因此,我建议使用由谷歌开发的Battery Historian来估算每个App的电池消耗量。但它是用Python / Go编写的。它将在html文件中显示硬件调用。您可以在相应的文本文件中找到每个应用程序的电池消耗。
https://developer.android.com/studio/profile/battery-historian.html "
它将创建一个batterystats.txt,显示与设置中的完全相同。