使用 Shark 来对你的 iPhone 应用进行性能调优(Using Shark to Performance Tune Your iPhone App)
2014-05-24 23:30
615 查看
使用 Shark 来对你的 iPhone 应用进行性能调优(Using Shark to Performance Tune Your iPhone App)
太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)本文遵循“署名-非商业用途-保持一致”创作公用协议转载请保留此句:太阳火神的美丽人生 - 本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。
使用 Shark 来对你的 iPhone 应用进行性能调优
问题是这样的:我们正处理一个 OpenGL 的 iPhone 游戏,不知什么原因桢率非常低 - 尤其有一些小的操作发生在屏幕上的时侯。我首先打算着手处理的是开始偿试成块注释掉系统部分,看看哪个模块导致的这个问题。我移除了物理系统、逻辑更新以及一些要被渲染的东西。然而,我什么也没做,好像就有显蓍的性能提升。现在该到时侯,深入点查看系统并让 Shark 找出问题出在哪儿了。
Here was the problem: we were working on an OpenGL iPhone game and for some reason the frame rates were unusually low - especially for what little action was happening on the screen at the time. My first plan of attack was to begin commenting out chunks of the system in an attempt to see what module was causing the problem. I removed the physics, the logic updates, and some of the things being rendered. Nothing I did, however, seemed to create a noticeable improvement in performance. It was now time to look a little deeper into the system and let Shark figure out what was wrong.
Shark 是一个性能描述工具,它作为 Xcode 工具的一部分,自从 Mac OS X 10.3 开始每一个版本都自带。本教程将向你介绍 Shark,如何使用它来描述一个 iPhone 应用,以及解释结果。
Shark is a performance profiling tool shipped with every version of Mac OS X 10.3 or newer. It comes as part of the Xcode Tools. This tutorial will introduce you to Shark, how to have it profile an iPhone application, and how to interpret the results.最先需要做的事情就是弄一份调试版本的应用下载到你的电话上。
The very first thing you're going to need to do it get a debug version of your app onto your phone. If you're to the point of wanting to use Shark, I'm going to assume you already know how to do this. To make the recording and analysis a little quicker, we're going to target your specific application, which means you'll want to go ahead launch it before you launch Shark. You'll also want to run your application outside of the Xcode debugger - just launch it directly using the phone.Up next, launch Shark. It should installed here:
At this point, your iPhone should be connected to the computer and your app should be running. When your phone appears in the list, simply check the box next to it. Shark should now look something like the image below.
Shark has several different configurations, however Time Profile is the one we'll be looking at today. This mode will tell us how much processing time is spent in what functions. Under Target, choose the app you'd like to profile. The current name of our app is "drop n lock", so that's what I have chosen. When everything is ready to go, just hit "Start".Shark doesn't let you view the performance information real-time. Simply do the actions you'd like performance information for and when you're done, hit "Stop". At this point, Shark is going to spend a long time analyzing the sample and then will create a session file that we can review.When the report is complete, it will display automatically.
There's lots of ways to view session information, however Tree (Top-Down) is the one I like the best. Looking at this report, we can see that the function responsible for rendering text is taking up 16% of the processing time. When I was first hunting for the problem, text rendering didn't even occur to me as a potential problem. And sure enough, when I disabled the text, my frame rate doubled. Obviously we'll need to find a more optimized way to display text.There you have it. Using Shark is a great way to find and eliminate performance bottlenecks in your iPhone applications. It took me no time at all to pin-point exactly where in our code a potential problem was. Unfortunately it can't fix the code for you - that you'll have to do on your own.
太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)本文遵循“署名-非商业用途-保持一致”创作公用协议转载请保留此句:太阳火神的美丽人生 - 本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。
使用 Shark 来对你的 iPhone 应用进行性能调优
Using Shark to Performance Tune Your iPhone App
问题是这样的:我们正处理一个 OpenGL 的 iPhone 游戏,不知什么原因桢率非常低 - 尤其有一些小的操作发生在屏幕上的时侯。我首先打算着手处理的是开始偿试成块注释掉系统部分,看看哪个模块导致的这个问题。我移除了物理系统、逻辑更新以及一些要被渲染的东西。然而,我什么也没做,好像就有显蓍的性能提升。现在该到时侯,深入点查看系统并让 Shark 找出问题出在哪儿了。
Here was the problem: we were working on an OpenGL iPhone game and for some reason the frame rates were unusually low - especially for what little action was happening on the screen at the time. My first plan of attack was to begin commenting out chunks of the system in an attempt to see what module was causing the problem. I removed the physics, the logic updates, and some of the things being rendered. Nothing I did, however, seemed to create a noticeable improvement in performance. It was now time to look a little deeper into the system and let Shark figure out what was wrong.
Shark 是一个性能描述工具,它作为 Xcode 工具的一部分,自从 Mac OS X 10.3 开始每一个版本都自带。本教程将向你介绍 Shark,如何使用它来描述一个 iPhone 应用,以及解释结果。
Shark is a performance profiling tool shipped with every version of Mac OS X 10.3 or newer. It comes as part of the Xcode Tools. This tutorial will introduce you to Shark, how to have it profile an iPhone application, and how to interpret the results.最先需要做的事情就是弄一份调试版本的应用下载到你的电话上。
The very first thing you're going to need to do it get a debug version of your app onto your phone. If you're to the point of wanting to use Shark, I'm going to assume you already know how to do this. To make the recording and analysis a little quicker, we're going to target your specific application, which means you'll want to go ahead launch it before you launch Shark. You'll also want to run your application outside of the Xcode debugger - just launch it directly using the phone.Up next, launch Shark. It should installed here:
/Developer/Applications/Performance Tools/SharkIn order to connect Shark to an iPhone, you'll need to change the sampling mode to Network/iPhone Profiling. You do this through Shark's Sampling menu.
At this point, your iPhone should be connected to the computer and your app should be running. When your phone appears in the list, simply check the box next to it. Shark should now look something like the image below.
Shark has several different configurations, however Time Profile is the one we'll be looking at today. This mode will tell us how much processing time is spent in what functions. Under Target, choose the app you'd like to profile. The current name of our app is "drop n lock", so that's what I have chosen. When everything is ready to go, just hit "Start".Shark doesn't let you view the performance information real-time. Simply do the actions you'd like performance information for and when you're done, hit "Stop". At this point, Shark is going to spend a long time analyzing the sample and then will create a session file that we can review.When the report is complete, it will display automatically.
There's lots of ways to view session information, however Tree (Top-Down) is the one I like the best. Looking at this report, we can see that the function responsible for rendering text is taking up 16% of the processing time. When I was first hunting for the problem, text rendering didn't even occur to me as a potential problem. And sure enough, when I disabled the text, my frame rate doubled. Obviously we'll need to find a more optimized way to display text.There you have it. Using Shark is a great way to find and eliminate performance bottlenecks in your iPhone applications. It took me no time at all to pin-point exactly where in our code a potential problem was. Unfortunately it can't fix the code for you - that you'll have to do on your own.
相关文章推荐
- 在iPhone应用中如何使用随机数(How to Use Random Numbers in Your iPhone App)
- (zz)How to sideload apps on your iPhone using Xcode 7(无需99刀也能在真机上测试App)
- How to Tune Your HBase Cluster 怎样对hbase进行内存调优
- how-to-automate-your-iphone-app-builds-with-hudson
- 利用缓存来提高网站的性能(Caching to Improve the Performance of Your Website )
- 使用 VisualVM 进行性能分析及调优
- 使用VisualVM进行性能分析及调优(转)
- Jboss应用使用jconsole进行性能监测
- 使用 VisualVM 进行性能分析及调优
- 使用 VisualVM 进行性能分析及调优
- UX Tuneup: 5 Ways to Improve Your iOS App
- iphone dev 入门实例7:How to Add Splash Screen in Your iOS App
- 10 Great iphone App Review sites to Promote your Apps!
- Using NuGet without committing packages to source control(在没有把包包提交到代码管理器的情况下使用NuGet进行还原 )
- 使用VS进行工作流开发系列博客3-Developing Workflows in VS: Part 2 - Planning Your Workflow: Two Things to Keep in Mind
- How to add CoverFlow Effect on your iPhone App – OpenFlow
- .NET性能调优之一:ANTS Performance Profiler的使用
- 使用window.performance进行浏览器性能测试
- 使用 VisualVM 进行性能分析及调优
- iOS Programming 101: How To Send Email in Your iPhone App