wince linux 性能,wince remote call profiler(性能分析)
如何使用
1 建立工程,CPU類型必須于目標(biāo)機(jī)型一致如ARMV4I,所以選擇WCE Application,然后選擇empty project
2 project settings 中,link頁(yè),Object/library modules中添加 cecap.lib(前面有空格),Ingore libraries中添加,libc.lib(前面有逗號(hào)).C/C++頁(yè)P(yáng)roject Options最后添加 /callcap(前面有空格)
cecap.lib 在C:Program FilesCommon FilesMicrosoft SharedWindows CE ToolsPlatmansdkwce500lib 下(wce500是目標(biāo)機(jī)器平臺(tái))
3 添加文件main.cpp,(文檔中要求必須include文件cecap.h,實(shí)際上可以不包含該文件)
4 編譯(確保Active Configuration是ARMV4I Debug)
5 運(yùn)行Remote Call Profiler,連接到目標(biāo)機(jī)器,如圖,選擇Start等待profilee運(yùn)行(也可以拷貝profilee到目標(biāo)機(jī)器,然后Launch)[@more@]
6 在EVC窗口上按CTRL+F5,下載運(yùn)行Profilee
7 回到Remote Call Profiler,可以看到Profile Data不再是No Data,點(diǎn)擊Finish
8 選擇菜單上Top X View,選擇剛才編譯出來(lái)的profilee.exe(需要從中導(dǎo)入Debug信息,這也是我們要編譯Debug版本的原因,否則看不到函數(shù)名等信息,只能看到函數(shù)偏移地址).可以看到,最耗時(shí)的函數(shù)列表
到這一步,不知道大家有沒(méi)有一個(gè)疑問(wèn),是不是我們的目標(biāo)機(jī)器在編譯鏡像的時(shí)候必須Enable Profiling.如果這樣,Remote Call Profiler的用途就受到了很大限制,比如很多機(jī)器我們沒(méi)有BSP或者Enable Profiling會(huì)導(dǎo)致應(yīng)用的運(yùn)行環(huán)境與最終產(chǎn)品有大的差異.所幸Enable Profiling不是必須的,看下面的原理:
原理及其進(jìn)一步的應(yīng)用用IDA反匯編profilee.exe,找到函數(shù)WinMain
.text:00011068 LDR R0, =WinMain
.text:0001106C BL _CAP_Enter_Function
.text:0001106C
.text:00011070 LDR R0, =s_Profilee
.text:00011074 BL NKDbgPrintfW
.text:00011074
.text:00011078 BL DoWork1
.text:00011078
.text:0001107C LDR R0, =s_End
.text:00011080 BL NKDbgPrintfW
.text:00011080
.text:00011084 LDR R0, =WinMain
.text:00011088 BL _CAP_Exit_Function
該處的源碼是
NKDbgPrintfW (L"========== Profilee ==========rn");
DoWork1();
NKDbgPrintfW (L"========== END ==========rn");
可以看到,函數(shù)的開(kāi)始處調(diào)用了_CAP_Enter_Function,結(jié)束處調(diào)用了_CAP_Exit_Function,顯然這是由于添加了編譯選項(xiàng)/callcap的緣故.而庫(kù)cecap.lib提供了這兩個(gè)函數(shù)的實(shí)現(xiàn).實(shí)際上我們工程里的每一個(gè)函數(shù)都同WinMain類似,可以想象,_CAP_XXX函數(shù)可以得到函數(shù)的運(yùn)行信息,并通過(guò)Remote Call Profiler以不同方式顯示出來(lái).
如果你覺(jué)得Remote Call Profiler不夠爽,自己實(shí)現(xiàn)_CAP_XXX好了,在里面做任何你想做的事情
fastcap
第2步,編譯選項(xiàng)從callcap改為fastcap,其他不變
同callcap相比,fastcap會(huì)計(jì)算出調(diào)用其他庫(kù)函數(shù)的時(shí)間了(如系統(tǒng)函數(shù)Sleep)
反匯編如下
.text:00011070 LDR R1, =NKDbgPrintfW
.text:00011074 LDR R0, =WinMain
.text:00011078 BL _CAP_Start_Profiling
.text:00011078
.text:0001107C LDR R0, =s_Profilee
.text:00011080 BL NKDbgPrintfW
.text:00011080
.text:00011084 LDR R0, =WinMain
.text:00011088 BL _CAP_End_Profiling
.text:00011088
.text:0001108C LDR R1, =DoWork1
.text:00011090 LDR R0, =WinMain
.text:00011094 BL _CAP_Start_Profiling
.text:00011094
.text:00011098 BL DoWork1
.text:00011098
.text:0001109C LDR R0, =WinMain
.text:000110A0 BL _CAP_End_Profiling
.text:000110A0
.text:000110A4 LDR R1, =NKDbgPrintfW
.text:000110A8 LDR R0, =WinMain
.text:000110AC BL _CAP_Start_Profiling
.text:000110AC
.text:000110B0 LDR R0, =s_End
.text:000110B4 BL NKDbgPrintfW
.text:000110B4
.text:000110B8 LDR R0, =WinMain
.text:000110BC BL _CAP_End_Profiling
總結(jié)
以上是生活随笔為你收集整理的wince linux 性能,wince remote call profiler(性能分析)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SEO基础知识
- 下一篇: linux 其他常用命令