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