监控网络和文件输入输出Monitor Network and File I/O
工具提供了几个分析模板,用于监视应用程序的网络和文件I/O活动。Instruments provides several profiling templates that monitor your app’s network and file I/O activity.
使用活动监视器跟踪整个网络和磁盘使用Use Activity Monitor to Track Overall Network and Disk Use
活动监视器概要模板使用活动监视器工具跟踪整个系统活动,包括CPU、内存、网络和磁盘。默认情况下,活动监视器模板不会在时间轴窗格中显示网络或磁盘活动。但是,您可以手动启用这些统计数据的显示。The Activity Monitor profiling template uses the Activity Monitor instrument to track overall system activity over time, including CPU, memory, network, and disk. By default, the Activity Monitor template doesn’t display network or disk activity in the timeline pane. However, you can manually enable the display of these statistics.
用活动监测仪记录网络和磁盘的使用To record network and disk use with the Activity Monitor instrument
- 运载工具。Launch Instruments.
- 在出现的剖析模板选择对话框中,单击活动监视器。In the profiling template selection dialog that appears, click Activity Monitor.
- 从目标设备和流程列表中选择您的设备和应用程序。Choose your device and app from the target device and process lists.
- 单击“选择”创建跟踪文档。Click Choose to create a trace document.
- 单击时间线窗格中的活动监视器工具。Click the Activity Monitor instrument in the timeline pane.
- 记者command-2显示督察窗格记录设置。Press Command-2 to show record settings in the inspector pane.
- 在“统计到列表”区域中,选择要查看的统计信息。然后,在系统统计区域中再次选择它们以启用它们。In the “Statistics to list” area, select the statistics you want to see. Then, select them again in the System Statistics area to enable them.
下面的统计信息与文件I/O有关:The following statistics pertain to file I/O:
- 磁盘读取操作(操作)Disk read ops (operations)
- 磁盘写操作Disk write ops
- 磁盘读取的字节数Disk bytes read
- 磁盘写入的字节Disk bytes written
- 每秒读取磁盘操作数Disk read ops per second
- 每秒磁盘写入操作数Disk write ops per second
- 每秒读取磁盘字节数Disk bytes read per second
- 每秒写入的磁盘字节数Disk bytes written per second
下面的统计信息涉及到网络I/O:The following statistics pertain to network I/O:
- 网络包(收到)Net packets in (received)
- 净数据包(发送)Net packets out (sent)
- NET字节Net bytes in
- NET字节Net bytes out
- 每秒净包数Net packets in per second
- 每秒净包Net packets out per second
- 每秒的净字节数Net bytes in per second
- 每秒净字节数Net bytes out per second
- 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button () in the toolbar (or press Command-R) to begin recording.
- 正常使用你的应用程序。Use your app normally.
- 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (), or press Command-R again, when complete.
- 检查收集的数据。Examine the collected data.
时间线窗格显示直观显示活动的图形。在详细窗格中找到了全面的活动信息。从详细窗格的导航栏中的“详细类型”列表中选择示例,以查看在采样周期期间捕获的所有数据。检查网络和磁盘列,以确定活动特别高时的准确时间。这些领域可能是批量交易,以获得更高的性能和能源效率。The timeline pane displays graphs visually denoting activity. Comprehensive activity information is found in the detail pane. Choose Samples from the detail type list in the navigation bar of the detail pane to see all data captured during the sample period. Examine the network and disk columns to pinpoint times when activity was especially high. These may be areas where you can batch transactions for greater performance and energy efficiency.
监控iOS应用程序的网络连接Monitor Network Connections of an iOS App
网络分析模板使用连接工具来分析您的IOS应用程序的TCP/IP和UDP / IP连接。The Network profiling template uses the Connections instrument to analyze your iOS app’s TCP/IP and UDP/IP connections.
记录IOS应用程序所使用的网络连接To record network connections used by your iOS app
- 把你的iOS设备连接到你的Mac。Connect your iOS device to your Mac.
您可以使用物理或无线连接。请参阅无线对象的iOS设备。You can use a physical or wireless connection. See Target an iOS Device Wirelessly.
- 运载工具。Launch Instruments.
- 在出现的分析模板选择对话框中,单击“网络”。In the profiling template selection dialog that appears, click Network.
- 从目标设备和流程列表中选择iOS设备和应用程序。Choose your iOS device and app from the target device and process lists.
- 单击“选择”创建跟踪文档。Click Choose to create a trace document.
- 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button () in the toolbar (or press Command-R) to begin recording.
- 正常使用你的应用程序。Use your app normally.
- 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (), or press Command-R again, when complete.
- 检查收集的数据。Examine the collected data.
在细节窗格的导航栏中使用详细类型列表,以通过进程、连接或网络接口(硬件)查看信息。Use the detail type list in the navigation bar of the detail pane to view information by process, connection, or network interface (hardware).
监视磁盘在OS X中的使用Monitor Disk Use in OS X
文件活动分析模板使用文件活动、读/写、文件属性和目录I/O工具来监视您的OS X应用程序的磁盘使用。The File Activity profiling template uses the File Activity, Reads/Writes, File Attributes, and Directory I/O instruments to watch your OS X app’s disk use.
记录您的OS X应用程序的文件活动To record the file activity of your OS X app
- 运载工具。Launch Instruments.
- 在出现的剖析模板选择对话框中,单击文件活动。In the profiling template selection dialog that appears, click File Activity.
- 从目标设备和流程列表中选择Mac和OS X应用程序。Choose your Mac and OS X app from the target device and process lists.
- 单击“选择”创建跟踪文档。Click Choose to create a trace document.
- 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button () in the toolbar (or press Command-R) to begin recording.
- 正常使用你的应用程序。Use your app normally.
- 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (), or press Command-R again, when complete.
- 单击时间轴窗格中的单个工具,在详细窗格中查看它们的活动。Click individual instruments in the timeline pane to view their activity in the detail pane.
每个工具都提供一个事件列表和一个调用树,您可以使用它来分析文件活动的特定实例。Each instrument provides an event list and a call tree, which you can use to analyze specific instances of file activity.
- 在详细窗格中选择要检查的事件。Select an event you want to inspect in the detail pane.
- 记者command-3显示在督察窗格扩展的详细地区选定的事件堆栈跟踪。Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector pane.
- 单击折叠按钮在扩展的详细地区隐藏在堆栈跟踪的系统调用。这样可以更容易地找到应用程序的方法。Click the Collapse button () in the extended detail area to hide system calls in the stack trace. This makes it easier to locate your app’s methods.
在你的应用程序进行调用的都是黑色的,之前有一个用户代码图标。Calls made by your app are colored black and preceded by a user code icon ().
- 双击堆栈跟踪中的一个方法,以在工具中显示其代码。Double-click a method in the stack trace to display its code in Instruments.
- 点击Xcode按钮在细节窗格顶部在Xcode打开代码编辑。Click the Xcode button () at the top of the detail pane to open the code in Xcode for editing.