Debugging Android Performance & Battery Issues--Like a Developer
Posted on Sat 15 August 2015 in android
I have a frustrating relationship with my phone's performance. I can cleanup my phone for a few days, but it tends to revert to being sluggish within no time. I've had dozens of devices and they all suffer from this.
There's a lot of voodoo about Android Performance and Battery life--task managers, factory resets, etc.
Here's a more developer-oriented process using adb .
Using ADB to identify process hogs
By connecting your device to the Android SDK, you can use ADB to identify process hogs. If you can, just remove the app. Otherwise, delete it's data (see
pm clear below)
$ adb shell dumpsys cpuinfo Load: 4.09 / 4.35 / 4.47 CPU usage from 17646ms to 1166ms ago with 99% awake: 6.1% 211690/com.android.settings: 4.3% user + 1.8% kernel / faults: 1341 minor 2.6% 294/surfaceflinger: 1.2% user + 1.3% kernel / faults: 38 minor ...
In this case the system settings app is using 6.1% cpu when the phone is idle. The workaround is to delete the app's data
$ adb shell pm clear com.android.settings Success
This is a trial-and-error process. But the results are both noticeable and measurable--a snappier UI, fewer background apps and a longer battery.