@测试代码中主要是增长了两个for循环,为了方便Time Profiler分析。 api
@(1) :图片右侧红色线框圈住的部分。CPU占用百分比。这里是刚启动的时候,CPU占用比较高。CPU 最大为400%,这里能够认为是MAC机器的CPU共计400%,但只分配给Simulator 100%。 ide
@(2) : 图片右侧蓝色线框圈住的部分。CPU使用的比较。因为是用Simulator进行演示分析,这里有MAC机器的其余程序也在运行。能够看到紫色部分是咱们的项目MSGS占用98%,Other Processes能够忽略不计。 函数
@(3) : 图片右侧紫色线框圈住的部分。CPU启动的时间。这里有三个参数。 工具
Duration:CPU运行时间 (7 sec) 测试
High: 最高占用比 (98%) spa
Low: 最低占用比 (13%) 线程
@(4): 图片右侧黑色线框圈住的部分。各个线程占用CPU的详情。刚启动时,只有一个主线程运行。 code
@(5): 图片右侧黄色线框圈住的部分。在Instruments里打开Time Profiler。 图片
@(1) :Restart,在Instruments从新启动项目进行Time Profiler分析。 get
@(2):Transfer,在Instruments中继续运行当前项目进行Time Profiler分析。
@(1): 紫色线框区域
:Record键,至关于开始和结束功能;
:Pause键,暂停功能,点击暂停后,项目将会终止加载
: 当前正在分析的项目
:项目的运行时间。注意这里有两个时间:
@(2): 蓝色线框区域
这里主要配合@(3)部分,设置其显示的方式。
Separate by Thread : 分开线程显示
Invert Call Tree: 以树形方式显示调用的方法
Hide System Libraries: 不显示系统函数占用时间
@(3): 红色线框区域
:这里能够选择调用函数占用时间显示方式,通常选择Call Tree方便查看。
:对应后面函数的运行时间和占用整个时间的百分比。
选中其中一行双击,便可查看到以下界面。这里显示了每一个操做所占用的时间比。(这里的运行之和为100%,即各个代码段在当前方法中的占用比,总和100%对应外部的90.2%)。
@对比图(此时项目运行到刚刚加载出游伴主界面后,选择暂停)
@: i = 100 ; j = 2000 ,UIApplicationMain()方法占用时间比为96.0%。
@:i = 1000 ; j = 20000,将循环放大一百倍。此时UIApplicationMain()方法占用时间比为33.8%
@1:打开某一个代码文件
@2:显示汇编调用和代码文件的对比
@3:在汇编代码和代码文件切换视窗
@4:在Xcode中打开代码段所在文件,使用选中代码片断必须是OC语言
@5:一些设置选项,能够显示值显示和百分比显示(目前还不知道x是什么单位)
@点击关闭按钮,会提示是否保存。这里能够保存成一个文件到指定目录
@1:保存的文件名
@2:保存位置
@所有的Instruments以下:
Trace template | Instruments |
---|---|
Activity Monitor |
Activity Monitor Instrument |
Allocations | Allocations Instrument VM Tracker Instrument |
Automation | Automation Instrument |
Cocoa Layout |
Cocoa Layout Instrument |
Core Animation |
Core Animation Instrument Time Profiler Instrument |
Core Data |
Core Data Cache Misses Instrument Core Data Fetches Instrument Core Data Saves Instrument |
Counters | Counters Instrument |
Dispatch | Dispatch Instrument |
Energy Diagnostics |
Bluetooth Instrument CPU Activity Instrument Display Brightness Instrument Energy Usage Instrument GPS Instrument Network Activity Instrument Sleep/Wake Instrument WiFi Instrument |
File Activity |
File Activity Instrument File Attributes Instrument Directory I/O Instrument Reads/Writes Instrument |
GPU Driver |
GPU Driver Instrument Time Profiler Instrument |
Leaks |
Allocations Instrument Leaks Instrument |
Multicore |
Dispatch Instrument Thread States Instrument |
Network | Connections Instrument |
OpenGL ES Analysis |
GPU Driver Instrument OpenGL ES Analyzer Instrument |
Sudden Termination |
Sudden Termination Instrument |
System Trace |
Scheduling Instrument System Calls Instrument VM Operations Instrument |
System Usage Time Profiler |
I/O Activity Instrument Time Profiler Instrument |
UI Recorder Zombies |
User Interface Instrument Allocations Instrument |
@从这里选择咱们要测试的项目