I am developing an application that tracks user movement using GPS and Network location information. I use Services, Activity Recognition, different sampling rates and gps/network timeouts for battery efficiency.
The question is How can I measure an exact amount (mV, mA/hour or % of total consumption) of power consumed by my App? Not only base on CPU usage, but also by calling GPS, Network, WiFi. So I can make a conclusion about the app battery efficiency.
I am getting battery statistic by adb shell dumpsys batterystats
.
This is what I see for 1 hour of usage during travelling by foot and train:
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)
I guess that the most power consuming thing are Sensor GPS calls, CPU usage and Wifi.
Questions:
1) How can I interpret this numbers? Is it possible to find out how much each GPS call (or realtime) is power expensive?
2) Is there are better ways to find out the total power consumption of the App?