天天看點

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  如需轉載請自行聯系原作者

繼續閱讀