Create, Save, and Open Trace Documents
在仪器中,所有的工作都是在跟踪文档中完成的,其中包含一组工具、它们的配置设置和它们收集的数据。一旦您使用跟踪文档来配置应用程序,就可以保存文档以保存收集的跟踪数据,并稍后再打开以便查看和分析。In Instruments, all work is done in a trace document, which contains a set of instruments, their configured settings, and the data they have collected. Once you profile an app with a trace document, you can save the document to preserve the trace data you have gathered and open it again later for viewing and analysis.
关于仿形模板About Profiling Templates
当设备启动时,它提供了一个分析模板(见图6-1)。每个模板包含一组工具,这些工具通常用于分析应用程序并收集有用信息,以帮助识别问题或提高应用程序的效率。When Instruments first starts up, it provides a list of profiling templates (see Figure 6-1). Each template contains a collection of instruments that are commonly used together to analyze an app and gather useful information in order to help identify problems or make your app more efficient.
如果需要为特定目的收集数据,您应该计划使用分析模板作为起点。例如,如果要检查内存问题的应用程序,应该选择与内存相关的模板,如分配、泄漏或僵尸。在使用模板创建跟踪文档之后,您可以随时添加或删除单个工具或重新配置工具。You should plan to use a profiling template as a starting point whenever you need to collect data for a particular purpose. For example, if you want to check your app for memory problems, you should choose a memory-related template, such as Allocations, Leaks, or Zombies. After using a template to create a trace document, you can always add or remove individual instruments, or reconfigure instruments, as needed.
有关可用模板及其所包含的工具的完整列表,请参见分析模板。For a complete list of available templates and the instruments they contain, see Profiling Templates.
创建跟踪文档Create a Trace Document
您需要创建跟踪文档以开始使用工具进行分析。You need to create a trace document to begin profiling with Instruments.
-
运载工具。Launch Instruments.
-
在出现的分析模板选择对话框中,选择目标设备和进程。In the profiling template selection dialog that appears, select a target device and process.
-
选择所需的分析模板。Select the desired profiling template.
-
Click Choose.
创建一个新的文档与预先设定的工具由您所选择的模板。A new document is created with the preconfigured instruments from the template you chose.
TIP
要在创建跟踪文档后自动开始对应用程序进行即时分析,请在分析模板选择对话框中按住选项键。执行此操作时,“选择”按钮会更改为配置文件。单击概要文件创建文档并立即开始分析。To automatically begin profiling your app immediately after creating the trace document, hold down the Option key in the profiling template selection dialog. When you do this, the Choose button changes to Profile. Click Profile to create the document and initiate profiling right away.
如果您找不到满足您需要的模板,或者只想从头创建自己的模板,请在剖析模板选择对话框中选择空白模板。If you can’t find a template to meet your needs or you just want to create your own from scratch, select the Blank template in the profiling template selection dialog.
保存跟踪文档Save a Trace Document
创建跟踪文档后,可以保存它以备以后参考。仪器将跟踪文档保存为跟踪扩展的工具跟踪文件。Once you’ve created a trace document, you can save it for later reference. Instruments saves trace documents as Instruments trace files with the .trace
extension.
-
Create a trace document. See To create a trace document.
-
Choose File > Save. Or, choose File > Save As if you want to save a previously saved trace document as a new file.
-
Enter a name for the file.
-
Choose a destination for the file.
-
Click Save.
保存跟踪文档作为分析模板Save a Trace Document as a Profiling Template
如果您创建了一个跟踪文档,您认为您可能需要再次分析其他应用程序,您可以将其保存为一个自定义模板,这样每次运行工具时不必重新创建它。If you create a trace document you think you might need again for profiling other apps, you can save it as a custom template so you don’t have to recreate it each time you run Instruments.
-
Create or open a trace document. See To create a trace document.
-
Choose File > Save As Template.
-
Enter a name for the template.
-
Choose a destination for the template.
将您的模板保存在用户/目录/应用程序支持/工具/模板目录中,以便在工具模板窗口的自定义部分中使用它。这是“保存为模板”对话框中的默认目录。Save your template in the
/Users/
<username>/Library/Application Support/Instruments/Templates
directory to make it available in the custom section of the Instruments template window. This is the default directory in the Save As Template dialog. -
Select an icon for the template.
-
Enter a description for the template.
-
Click Save.
保存模板后,它会自动出现在分析模板选择对话框中,并与自定义模板分组。下次创建跟踪文档时,可以选择它作为起始点。Once you save a template, it automatically appears in the profiling template selection dialog, grouped with the Custom templates. Next time you create a trace document, you can select it as your starting point.
Close a Trace Document
-
Choose File > Close (or press Command-W).
-
If your document contains unsaved data, select whether to save the updated document.
The document closes.
Open a Trace Document
Do one of the following:
-
Double-click the
.trace
document file in the Finder. -
Drag the
.trace
document file onto the Instruments app icon. -
Open Instruments and perform the following steps:
-
Choose File > Open (or press Command-O).
-
Locate a saved
.trace
document file. -
Click Open.
-
The trace document opens in Instruments.