Android 程式的效能追蹤

若你想要知道 Android 程式各階段 or 元件的效能追蹤,以便知道在哪裡比較費時, 可以參考下面方式 :

1) 在程式中, 啟動追蹤 :
Debug.startMethodTracing( "traceFileName" ); // 會在虛擬 SD 卡上, 產生 traceFileName.trace 檔案

2) 在程式中, 結束追蹤 :
Debug.stopMethodTracing( );

3) 在 Command Line, 從虛擬 SD 卡下載 Trace File :
adb pull /sdcard/traceFileName.trace .

4) 在 Command Line, 查看追蹤檔資訊 :
traceview 目前路徑\traceFileName.trace

運行 traceview 結果 :
Related Posts Plugin for WordPress, Blogger...