Android-bootchart and androidbootchart
Bootchart: android native boot performance display mechanism. By collecting various log data during the android boot process, the performance of each process during the boot process can be displayed in a chart. (Blog cannot be broken ...) It is not easy to write. The source must be noted for reprinting: http://blog.csdn.net/jscese/article/details/45933943this article is from the blog of [jscese! Compile bootchart
The source code of bootchart is \ system \ core \ init \ bootchart. c, which belongs to init.
Check the corresponding Android. mk, which has the following section:
ifeq ($(strip $(INIT_BOOTCHART)),true)LOCAL_SRC_FILES += bootchart.cLOCAL_CFLAGS += -DBOOTCHART=1endif
Obviously, the variable control is compiled. If you want to compile the bootchart into init, either the export variable is true or the value is defined.
There is also a corresponding bootchart. h header file with macro control in it. If you want to use bootchart, you will not have to say much about how to change it ~
Native startup is put in main of init. c:
#if BOOTCHARTqueue_builtin_action(bootchart_init_action, "bootchart_init");#endif
We can see that the first task is running in bootchart.Bootchart_initThis function
Let's take a look at the source code of bootchart. Here is a sentence:
Proc_read (LOG_STARTFILE, buff, sizeof (buff ));... int fd = open (LOG_ACCT, O_WRONLY | O_CREAT | O_TRUNC, 0644); // all the files under the/data Partition
The first proc_read reads a configuration time:/data/bootchart-start, which determines the start time and end time of the bootchart.
The second is the location where the captured log information is stored:/data/bootchart
The data Partition must be mounted first, so the bootchart must be started!
Use bootchart
After the system is compiled normally, you need to manually set the configuration mentioned above:
Echo 50>/data/bootchart-start // write 50 s
Restart the instance. If the instance runs normally, you can view the following five files under/data/bootchart:
root@86v:/ # ll /data/bootchart -rw-rw-rw- root root 517 2015-05-23 15:17 header-rw-r--r-- root root 0 2015-05-23 15:17 kernel_pacct-rwxr-xr-x root root 196608 2015-05-23 15:17 proc_diskstats.log-rwxr-xr-x root root 3735552 2015-05-23 15:17 proc_ps.log-rwxr-xr-x root root 131072 2015-05-23 15:17 proc_stat.log
Package as bootchart. tgz:
busybox tar zcvf bootchart.tgz header kernel_pacct proc_diskstats.log proc_ps.log proc_stat.log
The adb pull can be directly copied and put on the pc.
For ubuntu, you can use apt-get to install bootchart. You can use bootchart. tgz to parse it into a chart. There may be errors. Someone on the Internet has provided a method to modify the corresponding python script, which is not difficult.
Unfortunately, I am no longer in ubuntu, And it is inconvenient --
In Windows, you have to find a jar package corresponding to bootchart, which can be copied from the bootchart installation directory on ubuntu.
java -jar bootchart.jar bootchart.tgz
If there is no error, you can get a bootchart.png image, the previous image:
In general, blue indicates cpu usage, and pink indicates io wait, that is, the time consumed by file operations. The horizontal axis indicates the start time, which is described in process units.
Here we are ~