天天看点

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

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

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

// 开始跟踪然后自动保存到 "/sdcard/test.trace"      

Debug.startMethodTracing("test");      

// ...      

// 停止跟踪      

Debug.stopMethodTracing(); 

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

举个例子我们可以在:

//onCreate方法中调用   

onCreate(){ Debug.startMethodTracing("test"); }   

//.............     

//onPause 方法中结束   

onPause{ Debug.stopMethodTracing();   } 

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

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

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215846194.png"></a>

选择

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215853197.png"></a>

把我们要的trace文件拿出来

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215900967.png"></a>

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

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215907838.png"></a>

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215914742.png"></a>

以下是翻译

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215920552.jpg"></a>

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

<a target="_blank" href="http://blog.51cto.com/attachment/201202/215927453.png"></a>

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

<a href="http://blog.csdn.net/zjujoe/article/details/6080738">http://blog.csdn.net/zjujoe/article/details/6080738</a>

本文转自 liam2199 博客,原文链接: http://blog.51cto.com/youxilua/772691  如需转载请自行联系原作者

继续阅读