开启Instruments之旅吧

来源:互联网 发布:北航矩阵理论ab 编辑:程序博客网 时间:2024/06/11 19:37

Instruments这个app 存在于 xcode 之中,所以最直接的启动Instruments的方法就是从xcode里启动。你也可以直接的通过Dock这个渠道启动,点击Dock上的Launchpad,然后打开命令行终端。

通过Xcode使用Instruments:

启动Instruments最直接的方法就是在Xcode中通过Xcode顶部的菜单栏启动。


从Xcode菜单栏启动Instruments

1.打开Xcode.

2.选择菜单中的Xcode->Open Developer Tool->Instruments.



Tip:你可以通过这个方法启动许多有用的开发工具包。


你也可以为你在Xcode中正在运行的工作进行分析通过启动Instruments.

分析已经打开的Xcode项目:

1.启动Xcode并打开你的项目。

2.做下面任何一件事情:

>选择菜单栏上的Product->Profile


>在Xcode的工具栏中点击run按钮并保持点击状态,直到出现状态栏,选择Profile.


>组合键:command+I


Xcode运行了你的项目,Instruments开始启动,这个时候,被要求选择一个分析模块(工具):


如果你需要定期的通过同一个模板分析你的app,你可以设置Xcode自动使用它,无论什么时候启动Instruments.


设置Xcode使用一个特定的Instruments分析模板:

>启动Xcode并打开你的app

>选择顶部菜单栏Product->Scheme->Edit Scheme.


或者,在Xcode工具栏从Scheme的弹出菜单中,选择Edit Scheme.


或者,通过组合键:command+<

这个组合编辑对话框就会弹出来,如下:


>在组合编辑对话框的左侧工具条上选择Profile



>在Info下面,点击Instrument弹框并且选择你想要设置的分析模板


如果你选择“Ask on Launch“,Instruments 在被打开的时候会显示分析模板选择对话栏目。

5. 点击关闭。

6.初次进行性能分析,请看:分析已经打开的Xcode项目

在 Xcode中运行你的项目,启动Instruments,它会从一开始就运行你在scheme editor中配置的模板来对你的app进行性能分析。


Launchpad中启动Instruments

Launchpad自动显示了存在于你应用程序文件夹里的应用。由于Instruments不存在于应用程序文件夹中(至少,没有直接存在--它存在于Xcode这个app里),Instruments在Launchpad里不存在。不过,你可以通过创建一个别名把它添加到Instruments并且把它放到你的应用程序文件夹中。


添加Instruments到Launchpad

>打开Xcode.

>选择 Xcode->Open Developer Tool->Instruments


Instruments启动了,并且它的icon出现在了你的Dock上:


>在Dock上右键点击Instruments的图标,会弹出一个上下文联系的弹框

>选择Options(选项)->Show in Finder


>在Finder中拖拽Instruments的icon到你的应用程序文件夹中。这个就相当于在你的应用程序文件夹中创建了一个别名赋予Instruments.

>从Instruments别名文件后缀名上移除别名后缀。

   现在,在Launchpad里Instrument应该存在了。




从命令行启动Instruments

你可以通过OS X终端这个渠道来用命令启动任何应用。

通过打开命令行工具启动Instruments

>打开终端(在/Applications/Utilities).

>运行下面的命令:

open /Applications/Xcode.app/Contents/Applications/Instruments.app

Instruments就启动了。


NOTE

你还可以通过使用两个命令行使用工具去分析一个app,而不是在用户界面上实际显示Instruments。

· Instruments -- 它可以配置一个app使用一个特殊的模板。这个运行的结果可以保存到一个文件中,并且在Instruments主app中手动打开它,来进行  查看和分析,获取更多有用信息,请参   考" Profile with   instruments”和"instruments(1) Mac OS X Developer Tools Manual Page"。

·iprofiler--这个工具通过活动监听器监听app,Allocations,Counters,Event Profiler,Leaks,System Trace, and/or Time Profiler。结果会保存在一个 以.dtps结尾的文件中,一段时间之后你可以在Instruments中打开它来进行查看和分析。获取更多有用信息,请看“ Collect and view data with   iprofiler ”和“ iprofiler(1) Mac OS X Developer Tools Manual Page”。




原文链接地址“https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/LaunchingInstruments.html#//apple_ref/doc/uid/TP40004652-CH7-SW4”




0 0