TraceView

Traceview 用來追蹤程式執行效能,主要可運用2種方式來產生效能分析圖(.trace) A-1.使用插入code方式 在想分析的程式碼區塊插入Debug.startMethodTracing()及Debug.stopMethodTracing(); 其中Debug.startMethodTracing()可指定分析圖檔名如Debug.startMethodTracing("trace_report"),在/sdcard會產生trace_report.trace檔 A-2.加入<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> 否則A-1的方法會丟出Exception A-3.執行程式 A-4.將產生的分析圖從/sdcard中複製到本機的資料夾中以方便查看,使用以下指令 ./adb pull /sdcard/trace_report.trace /資料夾名稱 A-5.使用android-sdk tools的 traceview來開啟.trace檔,使用以下指令 android-sdk-linux/tools$ ./traceview /資料夾名稱/trace_report.trace B-1.使用DDMS來產生分析圖,執行程式並切換到DDMS B-2.點擊Start Method Profiling,開始分析 B-3.點擊Stop Method Profiling,結束分析 B-4.自動產生分析檔 以下提供簡單的分析範例,尋找程式效能熱點(HotPoint) 首先這是MainActivity MainActivity.java public...

XmlParser

網路上一堆範例不如自己作一遍還來的了解 直接切入主題,這裡使用DOM來轉換xml,以步驟來說明 Step1. 首先要有xml檔放到assets資料夾中,為了方便整理在assets 資料夾中另外開了一個xmlfiles資料夾,路徑如下 Project/assets/xmlfiles/command_simple_formatter.xml <?xml version="1.0" encoding="utf-8"?> <commands>     <command         id="1"         enable="true"         function_name="function1"         type="FLOAT" />     <command         id="2"         enable="false"         function_name="function2"         type="FIXED" /> </commands> Step2. 接著建立對應的資料結構,根據xml中的tag來建立 Command.java public class Command {     private int mIndex;     private String mFunction;  ...

MonkeyRunner 紀錄

紀錄: 首先MonkeyRunner主要是調用 /android-sdk-linux/tools/monkeyrunner 來自動化執行腳本 步驟1 在/android-sdk-linux/tools/中建立專屬的測試腳本資料夾,其中放入測試用腳本, 假設專案名稱為Project1,建立/android-sdk-linux/tools/Project1_script 步驟2 把專案apk(Project1.apk)放入步驟1建立的資料夾中並建立測試腳本(Project1_script.py), 測試腳本內容可參考以下範例,必須修改 device.installPackage('../Project1_script/Project1.apk') ->路徑必須對應apk位置 package = 'abc.efg.hij' -> package name activity = 'abc.efg.hij.xxxActivity' -> activity name 範例如下 Project1_script.py # Imports the monkeyrunner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage # Connects to the current device, returning a MonkeyDevice object device = MonkeyRunner.waitForConnection() # Installs the Android package. Notice that...

Git error: 解決在Gerrit網頁上submit patch set 出現衝突的情況

Cause: 在Gerrit等待code review通過期間,若有協同開發者先merge commit,且該commit和自己的commit 發生衝突的情況 Solution: 1. 在發生conflict 的 branch上 執行 git pull --rebase origin master 此指令說明如下 This command will fetch new commits from the remote and then rebase your local commits on top of them. It will temporarily set aside the changes you've made in your branch, apply all of the changes that have happend in master to your working branch, then merge (recommit) all of the changes you've made back into the branch. Doing this will help avoid future merge conflicts. Plus, it gives you an opportunity to test your changes against the latest code in master. Once you are satisfied with your change set and you've rebased against master, you are ready to push your code to Gerrit for review. 簡單的說:把master上已合併的commit(但在目前branch不存在),接到目前的branch上,再把 目前branch的commit接到最後面(最新) 當然在Gerrit網頁上合併會發生衝突,所以執行這個指令之後在本地端也會發生衝突,把執行後的提示紀錄下來如下 When you...

Eclipse Error: Indexer runs out of memory

Cause: 編譯jni會產生大量的檔案,特別是 C/C++ indexer 會建立索引 若eclipse初始記憶體太小會導致 out of memory 的錯誤 Solution: 在 eclipse.ini檔案中可設定記憶體限制,主要調整以下幾個數值 初始設定 --launcher.XXMaxPermSize 256m -XX:MaxPermSize=256m -Xms40m -Xmx512m 調整後 --launcher.XXMaxPermSize 512m -XX:MaxPermSize=512m -Xms80m -Xmx1000m 細節參考 http://wiki.eclipse.org/Eclipse....

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews