用好XCode性能工具
对于尝试调试和增强 iPhone 应用程序性能的人来说,使用 XCode 性能工具(例如泄漏监视器和 CPU 采样器)的最佳实践、技巧和教程是什么? 谢谢!
What are the best practices, tricks, and tutorials for using XCode's performance tools, such as the Leak Monitor and the CPU sampler, for someone trying to debug and enhance performance of an iPhone application?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这完全取决于应用程序以及您想要做什么。您是在尝试优化整个应用程序还是专注于特定的问题领域?您是否正在尝试减少内存使用量、CPU 使用量和/或使应用程序响应更快?
在开始性能分析之前,请使用静态分析器来分析您的代码。它通常会发现内存管理问题,这些问题会导致泄漏,从而导致您的应用程序可能在设备上崩溃。
一旦分析器发现的所有问题都得到解决,最好的方法就是从识别感知到的性能问题开始。也就是说,重点关注用户会注意到的性能问题。然后分析那些。如果可以的话,请对模拟器中运行的应用程序进行分析,因为周转时间会更快。
如果问题是膨胀之一,请使用对象分配和泄漏来找出原因。
如果这是一种滞后/缓慢的行为,请使用 CPU 工具来找出周期的去向。但请记住,缓慢的行为可能不是是因为CPU使用率,但可能是因为主事件循环被某些东西阻塞,很可能是不正确的并发模式。在这种情况下,您将在某种锁定或等待函数中看到主线程上的所有示例。
除此之外,您还需要确定特定场景才能得出特定答案。
It depends entirely on the application and on what you are trying to do. Are you trying to optimize the whole application or are you focused on a particular problem area? Are you trying to reduce memory usage, reduce CPU usage, and/or make the app more responsive?
Before you start the performance analysis, use the static analyzer to analyze your code. It will often find memory management problems that would lead to leaks that would cause your app to potentially crash on the device.
Once all of the analyzer identified problems have been fixed, the best approach is to start by identifying perceived performance problems. That is, focus on performance problems that the user would notice. Then analyze those. If you can get away with it, do the analysis on the app running in the simulator as the turnaround time is faster.
If the problem is one of bloat, use Object Alloc and Leaks to figure out why.
If it is one of laggy/sluggish behavior, use the CPU tools to figure out where the cycles are going. Keep in mind, though, that sluggish behavior may not be because of CPU usage, but may be because the main event loop is blocked by something, most likely incorrect concurrency patterns. In that case, you'll see all samples on the main thread in some kind of a lock or wait function.
Beyond that, you'll need to identify specific scenarios to yield specific answers.
在该用途中使用仪器
对象分配
活动监视器,
泄漏
memoer 监控
并测试您的应用程序
use instruments in that use
object allocation
activity monitor,
leaks
memoer monitor
and test your app