一、system_server视角
1.1 logcat
perf-cb生效后,这些日志成输出到logcat,他们记录关键的调用如:Activity.callActivityOnStop,并且包括详细的参数。
07-17 20:06:42.986 4009 4009 I APP-CB : 0168.836: => Activity.callActivityOnStop(com.letv.android.letvlive.main.MainActivity@1cd070be)
...
07-17 20:06:43.242 4009 4009 I APP-CB : 0169.092(0000.256s): <- Activity.callActivityOnStop(com.letv.android.letvlive.main.MainActivity@1cd070be)
相关的文档见特性: perf-cb
1.2 perf-cb
perb-cb.py是一个解析工具,用来解析perf-cb相关的日志内容,并且过滤出时间消耗高于delta-time(默认值200ms)的调用,按消耗时间倒序排列。
1.3 usage
python perf_cb.py --logcat-file="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1"
python perf_cb.py --logcat-dir="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01"
python perf_cb.py --logcat-file="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1" --logcat-dir="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01"
1.4 实例
- 命令行
$ python perf_cb.py --logcat-file="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1"
- 结果
$ python perf_cb.py --logcat-file="/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1" ['--logcat-file=/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1'] parse_file(/disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1, log_data_list) /disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1:16461 07-17 19:51:15.352 4870 4870 I APP-CB : 0059.290(0006.516s): <- Instrumentation.callActivityOnCreate(com.stv.deskplatform.ui.activity.Launcher@29658b18, null) /disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1:9763 07-17 19:50:55.098 4018 4018 I APP-CB : 0039.034(0005.660s): <- Instrumentation.callApplicationOnCreate(com.letv.android.letvlive.LiveAppApplication@2e5a9472) /disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1:9133
输出内容包括文件名:行数。通过文本编辑器可以直接打开并定位到该行数。
subl /disk2/thomas/sjPBP/SDE/Android/AAF/am/01/logcat.log.1:16461
通过搜索可以找到对应的开始和结束的日志。
07-17 19:51:08.836 4870 4870 I APP-CB : 0052.774: => Instrumentation.callActivityOnCreate(com.stv.deskplatform.ui.activity.Launcher@29658b18, null) 07-17 19:51:15.352 4870 4870 I APP-CB : 0059.290(0006.516s): <- Instrumentation.callActivityOnCreate(com.stv.deskplatform.ui.activity.Launcher@29658b18, null)
二、应用进程
开发者可以过滤出关于该进程Info这个级别的日志,分析其中的耗时部分,找出其中的瓶颈。
| 微博 weibo.com/liuxk99