@測試代碼中主要是增長了兩個for循環,爲了方便Time Profiler分析。 api
@(1) :圖片右側紅色線框圈住的部分。CPU佔用百分比。這裏是剛啓動的時候,CPU佔用比較高。CPU 最大爲400%,這裏能夠認爲是MAC機器的CPU共計400%,但只分配給Simulator 100%。 ide
@(2) : 圖片右側藍色線框圈住的部分。CPU使用的比較。因爲是用Simulator進行演示分析,這裏有MAC機器的其餘程序也在運行。能夠看到紫色部分是咱們的項目MSGS佔用98%,Other Processes能夠忽略不計。 函數
@(3) : 圖片右側紫色線框圈住的部分。CPU啓動的時間。這裏有三個參數。 工具
Duration:CPU運行時間 (7 sec) 測試
High: 最高佔用比 (98%) spa
Low: 最低佔用比 (13%) 線程
@(4): 圖片右側黑色線框圈住的部分。各個線程佔用CPU的詳情。剛啓動時,只有一個主線程運行。 code
@(5): 圖片右側黃色線框圈住的部分。在Instruments裏打開Time Profiler。 圖片
@(1) :Restart,在Instruments從新啓動項目進行Time Profiler分析。 get
@(2):Transfer,在Instruments中繼續運行當前項目進行Time Profiler分析。
@(1): 紫色線框區域
:Record鍵,至關於開始和結束功能;
:Pause鍵,暫停功能,點擊暫停後,項目將會終止加載
: 當前正在分析的項目
:項目的運行時間。注意這裏有兩個時間:
@(2): 藍色線框區域
這裏主要配合@(3)部分,設置其顯示的方式。
Separate by Thread : 分開線程顯示
Invert Call Tree: 以樹形方式顯示調用的方法
Hide System Libraries: 不顯示系統函數佔用時間
@(3): 紅色線框區域
:這裏能夠選擇調用函數佔用時間顯示方式,通常選擇Call Tree方便查看。
:對應後面函數的運行時間和佔用整個時間的百分比。
選中其中一行雙擊,便可查看到以下界面。這裏顯示了每一個操做所佔用的時間比。(這裏的運行之和爲100%,即各個代碼段在當前方法中的佔用比,總和100%對應外部的90.2%)。
@對比圖(此時項目運行到剛剛加載出遊伴主界面後,選擇暫停)
@: i = 100 ; j = 2000 ,UIApplicationMain()方法佔用時間比爲96.0%。
@:i = 1000 ; j = 20000,將循環放大一百倍。此時UIApplicationMain()方法佔用時間比爲33.8%
@1:打開某一個代碼文件
@2:顯示彙編調用和代碼文件的對比
@3:在彙編代碼和代碼文件切換視窗
@4:在Xcode中打開代碼段所在文件,使用選中代碼片斷必須是OC語言
@5:一些設置選項,能夠顯示值顯示和百分比顯示(目前還不知道x是什麼單位)
@點擊關閉按鈕,會提示是否保存。這裏能夠保存成一個文件到指定目錄
@1:保存的文件名
@2:保存位置
@所有的Instruments以下:
Trace template | Instruments |
---|---|
Activity Monitor |
Activity Monitor Instrument |
Allocations | Allocations Instrument VM Tracker Instrument |
Automation | Automation Instrument |
Cocoa Layout |
Cocoa Layout Instrument |
Core Animation |
Core Animation Instrument Time Profiler Instrument |
Core Data |
Core Data Cache Misses Instrument Core Data Fetches Instrument Core Data Saves Instrument |
Counters | Counters Instrument |
Dispatch | Dispatch Instrument |
Energy Diagnostics |
Bluetooth Instrument CPU Activity Instrument Display Brightness Instrument Energy Usage Instrument GPS Instrument Network Activity Instrument Sleep/Wake Instrument WiFi Instrument |
File Activity |
File Activity Instrument File Attributes Instrument Directory I/O Instrument Reads/Writes Instrument |
GPU Driver |
GPU Driver Instrument Time Profiler Instrument |
Leaks |
Allocations Instrument Leaks Instrument |
Multicore |
Dispatch Instrument Thread States Instrument |
Network | Connections Instrument |
OpenGL ES Analysis |
GPU Driver Instrument OpenGL ES Analyzer Instrument |
Sudden Termination |
Sudden Termination Instrument |
System Trace |
Scheduling Instrument System Calls Instrument VM Operations Instrument |
System Usage Time Profiler |
I/O Activity Instrument Time Profiler Instrument |
UI Recorder Zombies |
User Interface Instrument Allocations Instrument |
@從這裏選擇咱們要測試的項目