码迷,mamicode.com
首页 > 其他好文 > 详细

Instruments_Activity Monitor使用入门

时间:2015-09-08 01:48:58      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:

在之前的文章说过Activity Monitor,官方解释为:(活动监视器)实时显示CPU、内存和网络的使用情况,记录由虚拟内存大小测量的系统负载。用一句大白话来说,Activity Monitor类似Windows中的任务管理器,可以实时查看进程占用的CPU、内存的使用量。
 
一、Activity Monitor的介绍和大致使用
具体操作步骤,
首先从Xcode中运行Instruments,在顶部的菜单栏中,选择Product,选择Profile(快捷键:Command + I)。会调用Instruments,选择Activity Monitor 模板
技术分享

Activity Monitor打开之后是这个样子,所有都是空的
技术分享
 
 当运行的设备和运行的app的准备好了,我们开始运行Activity Monitor,点击左上角的红色圆点按钮,开始记录手机中CPU和内存的使用情况,点击Activity Monitor左上角的暂停按钮,就得到下图:
技术分享
我们分析一下这些图的意思吧:
%CPU:不同进程对CPU的占比
CPU Time:CPU运行时间
Real Memory Usage:进程使用的内存量,用了饼状图和柱状图展示
 
 
上图只是这些数据的大概结果我们可以去查看具体的数据,点击上图4个任意自己想要查看信息的图片,分析的结果有4种分析结果【Summary、Parent Child、Samples、Console】,我们一个个来分析
(1)Summary
技术分享
其中参数的含义如下:                             
process id :进程id 
process name :进程名 
user name:用户名
%CPU:cpu占比
threads:线程
real mem:真正使用的内存 
virtual mem:虚拟内存
architecture:架构 
cpu time:CPU时间 
sudden term:突如其来的项 
 
 (2)Parent Child
技术分享
 
 它的参数与Summary是一样的,内容也是一样的,就是多了点击进程1的地方多了一个隐藏功能
 
(3)Samples
技术分享
参数的含义如下:
total thread:总线程 
physical memory wired:物理内存连接大小
physical memory active:活动的物理内存大小 
physical memory Inactive:不活动的物理内存大小 
physical memory used:使用的物理内存大小
 
 (4)Console,即控制台输出的日志(Log)信息
技术分享
  
二、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监控网络情况 

Following Network Usage Through 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. 

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

技术分享 

 
 
 
参考以下文章:

Instruments_Activity Monitor使用入门

标签:

原文地址:http://www.cnblogs.com/JuneWang/p/4789910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!