Activity Monitor使用說明

Activity Monitor,官方解釋爲:(活動監視器)即實時顯示CPU、內存和網絡的使用情況,記錄由虛擬內存大小測量的系統負載。用一句大白話來說,Activity Monitor類似Windows中的任務管理器,可以實時查看進程佔用的CPU、內存的使用量。
 
一、Activity Monitor的介紹和大致使用
具體操作步驟,
首先從Xcode中運行Instruments,在頂部的菜單欄中,選擇PRoduct,選擇Profile(快捷鍵:Command + I)。會調用Instruments,選擇Activity Monitor 模板


Activity Monitor打開之後是這個樣子,所有都是空的
 
 當運行的設備和運行的app都準備好了,我們開始運行Activity Monitor,點擊左上角的紅色圓點按鈕,開始記錄手機中CPU和內存的使用情況,得到下圖:
我們分析一下這些圖的意思:
%CPU:不同進程對CPU的佔比
CPU Time:CPU運行時間
Real Memory Usage:進程使用的內存量,用了餅狀圖和柱狀圖展示
 
上圖只是這些數據的大概結果我們可以去查看具體的數據,點擊上圖4個任意自己想要查看信息的圖片,分析的結果有4種分析結果【Summary、Parent Child、Samples、Console】,我們一個個來分析
 
(1)Summary(Summary of data) ---------Process(進程)使用內存、CPU使用時長等摘要信息
其中參數的含義如下:                             
process id ——進程id 
process name ——進程名 
user name——用戶名
%CPU——cpu佔比
threads——線程
real mem——真正使用的內存 
virtual mem——虛擬內存
architecture——架構 
cpu time——CPU時間 
sudden term——突然項(N/A:不適用) 
 
(2)Parent Child( 

parent child information)-----父進程和子進程的關係,以及各個進程的概要信息

 
 它的參數與Summary是一樣的,內容也是一樣的。但是它具有層級關係(即父子關係),子進程在父進程的下一層級。(父進程上,可以展開、關閉它的所有子進程)
 
(3)Samples(a list of samples) ----一系列抽樣(即不同時間,CPU使用時間、內存使用情況的樣本值)
參數的含義如下:
  • Physical Memory Wired——操作系統佔用的內存
  • Physical Memory Active——除操作系統外其它進程佔用的內存
  • Physical Memory Inactive——最近被釋放的內存
  • Physical Memory Used——profiling當前進程時使用的總內存
  • Physical Memory Free——當前的可用內存
  • Total VM Size——虛擬內存的佔用量 
 
(4)Console,即控制檯輸出的日誌(Log)信息
 
提示:
Activity Monitor默認配置了在Timeline面板中顯示的內容,包括TotalVMSizeCPUTotalLoadCPUUserLoadCPUSystemLoad,在使用時可以根據自己的需要選擇相關的分析內容進行顯示,並且不同的內存使用部分可以使用不同的顏色加以區分,下面就是Activity Monitor在使用過程中的界面截圖,在右下角可選擇內存相關的分析內容。

 

下面我們將根據需要,對Activity Monitor監控的內容進行分類介紹:
  
二、Activity Monitor監控內存使用情況

Examining Memory Usage with the Activity Monitor Trace Template

The Activity Monitor trace template monitors overall system activity and statistics, including CPU, memory, disk, and network. It consists of the Activity Monitor instrument only, although you can add additional instruments to a trace document you’ve created with the template, if you desire. You’ll see later that the Activity Monitor is also used to monitor network activity on iOS devices.

The Activity Monitor instrument captures information about the load on the system measured against the virtual memory size. It can record information from a single process or from all processes running on the system. The Activity Monitor instrument provides you with four convenient charts for a quick, visual representation of the collected information. The two charts that specifically describe memory usage are:

Real Memory Usage (bar graph). Shows the top five real memory users in a bar graph.

Real Memory Usage (pie chart). Shows the top five real memory users with the total memory used displayed.

下圖爲Activity Monitor instrument with charts

 

The Record Settings area in the inspector sidebar includes a list of system statistics, which can be configured to appear in the track pane and graphically represent collected data. Select a statistic’s checkbox to see it graphed in the track pane. Click the shape or the color well to change how a statistic appears in the track pane.

There are a number of statistics the Activity Monitor instrument supports, but the following ones are memory-specific:

Physical Memory Wired

Physical Memory Active

Physical Memory Inactive

Physical Memory Used

Physical Memory Free

Total VM Size

VM Page In Bytes

VM Page Out Bytes

VM Swap Used

If one of the statistics above doesn’t appear under System Statistics, locate it under “Select statistics to list” and click its checkbox to include it in the list. 

 
三、Activity Monitor監控CPU情況 
There are a number of statistics the Activity Monitor instrument supports, but the following ones are memory-specific:

CPUTtotalLoad
CPUUserLoad
CPUSystemLoad
CPUNiceLoad

If one of the statistics above doesn’t appear under System Statistics, locate it under “Select statistics to list” and click its checkbox to include it in the list. 
下圖爲Activity Monitor instrument tracing CPU packets
 
四、Activity Monitor監控網絡情況 

By default, the Activity Monitor template isn’t set up to display network activity. Therefore, you need to enable the desired network-related statistics in the Record Settings area in the inspector sidebar for the Activity Monitor instrument to see which processes are sending and receiving information.

There are a number of statistics the Activity Monitor instrument supports, but the following ones are network-specific:

Net Packets In
Net Bytes In
Net Packets Out
Net Bytes Out
Net Packets In Per Second

Net Packets Out Per Second

Net Bytes In Per Second

Net Bytes Out Per Second

If one of the statistics above doesn’t appear under System Statistics in the Record Settings inspector, locate it under “Select statistics to list” and click its checkbox to include it in the list. 

Once you have gathered network activity for your app, examine it carefully to pinpoint areas where your app is sending out excessive amounts of information and therefore tying up valuable device resources. When you minimize the amount of information sent and received, you can benefit from increased performance and response times in your app.

下圖爲Activity Monitor instrument tracing network packets




轉載自:http://www.cnblogs.com/JuneWang/p/4789910.html   需要可以訪問

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章