application development.
在第7章,你已经学习了使用debugger找到并解决bug。现在让我们学习ios编程中其它有益的工具。
Gauges
Xcode 5 introduced debug gauges that provide at-a-glance information about your application’s CPUand memory usage.
a numerical figure describing that resource’s current usage.
gauges 实时显示了应用占用内存和cpu。
run your application in the iOS Simulator, your CPU and memory usage will appear to be very low.
注意最好是在真机上测试。
Click on the CPU Debug Gauge. This will present the CPU Report in the Editor pane (Figure 14.2).
The report contains four basic sections:
Percentage Utilized
shows your CPU utilization relative to the number of CPU cores your device has. For example,
dual-core devices will show CPU usage out of 200%. While your application is idle, this should
read 0%.
显示应用的cpu占用率
Utilization Comparison
allows you to see your application’s CPU usage as it impacts the rest of the system. At any given
time, your application is not the only cause of activity on the device. Some applications may be
running in the background, putting their own pressure on the system. If your app feels slow but is
not using much CPU on its own, this may be why.
相比其他进程,应用占用cpu的比率。有可能有后台进程影响了系统。
Utilization over Time
graphs your application’s CPU usage and shows how long the application has been running, as
well as peak and trough usage values over the course of the current run.
应用运行过程cpu占用图
Threads
shows a the breakdown of the Utilization over Time graph on a per-thread basis. Multithreading is
outside the scope of this book, but this information will become useful to you as you continue your
iOS development education and career.
To make the graph a bit less boring, begin drawing a line but continue moving your finger without ever
letting the line lock into place. This will cause a sustained spike in CPU usage.