Trace工具分析代码执行时间
1、*Debug.startMethodTracing(filePath);
中间为需要统计执行时间的代码
Debug.stopMethodTracing();
2、adb pull /storage/emulated/0/app1.trace把文件拉出来分析
把pull到电脑上的文件拖到AS中就可以分析了
3、*优化方案:
1.开线程 没建handler 没操作UI 对异步要求不高
2.懒加载 用到的时
候再初始化,如网络,数据库操作
1.找到生成的trace文件

2.导入到AS中


3.找到关心的线程

4.找到方法名,用时上面也会有标注

当然也可以用AS的工具直接记录


当用到Tace System Calls 会有一些其他你可能会关心的数据展示如下


AS 的profile工具越来越强大了,具体其他自己探索!
网友评论