第十四章 Debugging Tools

14
Debugging Tools
In Chapter 7, you learned about using the debugger to find and fix problems in your code. Now we are
going to look at other tools available to iOS programmers and how you can integrate them into your

application development.

在第7章,你已经学习了使用debugger找到并解决bug。现在让我们学习ios编程中其它有益的工具。


Gauges

第十四章 Debugging Tools_第1张图片

Xcode 5 introduced debug gauges that provide at-a-glance information about your application’s CPU

and memory usage.


Open your TouchTracker project and run it, preferably on a provisioned iOS device rather than the iOS
Simulator. In the navigator, select the tab to open the debug navigator.
Figure 14.1 Gauges
While the application is running (not paused or crashed), the debug navigator shows CPU and memory
gauges (Figure 14.1). Each of these shows a live-updating graph of resource usage over time, as well as

a numerical figure describing that resource’s current usage.

gauges 实时显示了应用占用内存和cpu。


Important note: these gauges scale based on the hardware that is actually running your application.
Your Mac has much more available RAM and likely more CPU cores than iOS devices do, so if you

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).

第十四章 Debugging Tools_第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.
















你可能感兴趣的:(第十四章 Debugging Tools)