Bootchart provides CPU and I/O load breakdown of all processes for the whole system. It doesn’t require rebuilding system image and can be used as a quick sanity check before diving into systrace.
Install dependencies on Ubuntu Desktop / laptop
$ sudo apt install pybootchartgui
Download the source code to get the grab-bootchart.sh script from system/core/init from android aosp,
$ git clone https://android.googlesource.com/platform/system/core
Now, lets connect your android device over adb shell and there we have to enable bootchart so that in next reboot it can capture the necessary logs as,
$ sudo adb kill-server
$ adb devices
Make sure you are seeing your device listed in adb devices. Once you start adb shell, we need to create an empty file “/data/bootchart/enabled” which enables boot chart during the next reboot of device.
$ adb shell
$ touch /data/bootchart/enabled
$ ls -alh /data/bootchart/
-rw-rw-rw- 1 shell shell 0 2020-xx-xx 23:40 enabled
Now reboot device.
$ reboot
Once you see the android device is booted completely after reboot, wait for a while and then on Ubuntu machine, you will need to run following commands to grab boot time logs and generate an image which shows the CPU usage and process details during the booting.
Connect adb and try On Ubuntu Desktop
$ cd system/core/init
$ bash grab-bootchart.sh
This should generate bootchart.png in your current directory i.e. system/core/init and open a bootchart.png image which you can also save to any location as you want.
Now, to disable boothcart completely during next boot,
$ adb shell
$ rm -rf /data/bootchart/*