且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有关于如何使用Shark和iPhone来衡量性能的快速指南?

更新时间:2023-11-12 13:58:10

这个答案提供了将Shark连接到正在运行的实例的分步指南您在iPhone上的应用程序。

This answer provides a step-by-step guide to connecting Shark to a running instance of your application on an iPhone.

至于如何使用Shark的教程,有以下内容:

As far as tutorials on how to use Shark, there are the following:

  • "Optimizing Your Application with Shark 4"
  • "Optimizing with Shark: Big Payoff, Small Effort"
  • "Optimizing Your Application with System Trace in Shark 4"
  • "Using Shark and custom DTrace probes to debug Nagios on Mac OS X"

您可以使用Shark执行的最强大的功能是对应用程序执行时间配置文件,然后右键单击低级符号(objc_msgSend等)并将符号或库充电给其调用者。这很快就可以让你确定你的方法占用了大部分CPU时间。

Among the most powerful things you can do with Shark is to do a time profile of your application, then right-click on the low-level symbols (objc_msgSend, etc.) and charge the symbol or library to its caller. This very quickly lets you determine what methods of yours are chewing up the most CPU time.

在处理多线程应用程序时,我觉得进行系统跟踪很有用检查时间线以查看各种线程何时执行。您可能希望显示高级控件(窗口|显示高级设置)以启用更多可视化选项。一台Mac,它可以用来打开CPU着色,但这在当前的iPhone上几乎没用。

When dealing with multithreaded applications, I find it useful to do a system trace and then examine the timeline to see when various threads were executing. You may wish to show the advanced controls (Window | Show Advanced Settings) to enable more visualization options. One the Mac, it can be useful to turn on CPU coloring, but that's of little use on the current iPhones.

我个人建议拿起来自今年会议的WWDC视频。如果您只使用iPhone轨道,它们的价格是299美元。有几个会话展示了如何使用Shark和Instruments来调整iPhone应用程序。此外,如果您支付ADC Select会员资格,您将可以访问以前WWDC会议中使用Shark的多个视频。我从这些视频中了解了大部分关于Shark的知识。

Personally, I would suggest picking up the WWDC videos from this year's conference. If you only take the iPhone track, they are a great deal at $299. There are a couple of sessions that show how to use Shark and Instruments to tune iPhone applications. Additionally, if you pay for the ADC Select membership, you'll have access to several videos on using Shark from previous WWDC conferences. I learned most of what I know about Shark from these videos.