1.在开始使用TraceView你要注意:

  你的设备和模拟器必须设置SD card 和 你的程序拥有对SD card 具有读写操作的权限(

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />)

2.在你的程序中使用TraceView

 // 开始跟踪然后自动保存到 "/sdcard/test.trace"
    Debug.startMethodTracing("test");
    // ...
    // 停止跟踪
    Debug.stopMethodTracing();

使用traceView就只需要这两个方法了…

举个例子我们可以在:

//onCreate方法中调用
onCreate(){
Debug.startMethodTracing("test");
}
//.............

//onPause 方法中结束
onPause{
Debug.stopMethodTracing();

}

当然,你Debug的位置你可以随便设置,只要符合要求就行

然后,结束调试好,你会在eclipse 中的file explorer 中看到生成的文件

android TraceView (图形化性能测试工具)使用入门笔记

选择

android TraceView (图形化性能测试工具)使用入门笔记

把我们要的trace文件拿出来

android TraceView (图形化性能测试工具)使用入门笔记

这里注意,文件路径要大全,不然,无法显示…

时间片面板(Timeline panel)

android TraceView (图形化性能测试工具)使用入门笔记

分析面板(Profile panel)

android TraceView (图形化性能测试工具)使用入门笔记

以下是翻译

英语 中文
Incl 调用方法占用时间百分比
Inclusive 调用方法时间(ms)(包括了所有方法的调用)
Excl 执行方法占用时间百分比
Exclusive 执行方法占用时间(ms)(不包括子方法的调用)
Calls+Recur Calls/Total 调用和重复调用的次数
Time/Call 总的时间(ms)

 

文档中提及一个dmtracdedump 的工具 要预装Graphviz ,而且,还要写pytho脚本才能用…

android TraceView (图形化性能测试工具)使用入门笔记

效果就是这样,有兴趣的可以参考:

http://blog.csdn.net/zjujoe/article/details/6080738

相关文章:

  • 2021-12-05
  • 2021-04-07
  • 2021-06-09
  • 2021-04-01
  • 2021-11-10
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2021-12-05
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-05-04
  • 2022-12-23
相关资源
相似解决方案