使用 Shark 来对你的 iPhone 应用进行性能调优(Using Shark to Performance Tune Your iPhone App)

太阳火神的美丽人生 (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 是一个性能描述工具,自从 Mac OS X 10.3 开始每一个版本都自带。它作为 Xcode 工具的一部分。本教程将向你介绍 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/Shark

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

使用 Shark 来对你的 iPhone 应用进行性能调优(Using Shark to Performance Tune Your iPhone App)

时间: 2024-10-09 17:27:00

使用 Shark 来对你的 iPhone 应用进行性能调优(Using Shark to Performance Tune Your iPhone App)的相关文章

ANDROID学习之路 转

版权声明:本文为 stormzhang 原创文章,可以随意转载,但必须在明确位置注明出处!!! 这篇博客背后的故事 一路走来很不容易,刚好知乎上被人邀请回答如何自学android编程, 就借这个机会在知乎上记录一路走来的历程,很励志,希望能给那些正在或准备走编程行业的人一些正能量,内容有点长,感兴趣的可以当做励志小说阅读吧. 收到一些朋友的微博私信,说能不能给Android新手们一些指导,我只能说指导谈不上,毕竟我也很多东西正在学习中,与此同时一大学同学准备转行Android,可以说是从头开始,

Android自学绝佳资料

本文转自stormzhang老师的博客:http://stormzhang.com/android/2014/07/07/learn-android-from-rookie 首先感谢stromzhang老师的无私分享,让迷惘的android新手找到前进的方向,如获至宝,相见恨晚,因此,保存收藏以便随时学习(本文里的链接貌似都打不开……),同时希望更多android新手能够早日看到这篇好文章!再次感谢stormzhang老师!关注张老师的微博或微信公共号,可以第一时间获得很多很多干货哦. 书籍 书

安卓学习之路

2015.4.7 安卓官方培训教程:http://hukai.me/android-training-course-in-chinese/index.html 来自知乎:一位大神的推荐.目前还停留在刚刚看完<第一行代码>的阶段,惭愧. http://www.stormzhang.com/android/2014/07/07/learn-android-from-rookie/ 硬件 电脑–推荐Mac 首先声明我不是果粉,个人Windows,Linux,Mac OX系统均用过, 只能说Windo

android学习之路资料集合

版权声明:本文为 stormzhang 原创文章,可以随意转载,但必须在明确位置注明出处!!! 这篇博客背后的故事 一路走来很不容易,刚好知乎上被人邀请回答如何自学android编程, 就借这个机会在知乎上记录一路走来的历程,很励志,希望能给那些正在或准备走编程行业的人一些正能量,内容有点长,感兴趣的可以当做励志小说阅读吧. 收到一些朋友的微博私信,说能不能给Android新手们一些指导,我只能说指导谈不上,毕竟我也很多东西正在学习中,与此同时一大学同学准备转行Android,可以说是从头开始,

分享 stormzhang的Andoid学习之路

硬件 电脑–推荐Mac 首先声明我不是果粉,个人Windows,Linux,Mac OX系统均用过, 只能说Windows上面的开发工具简直难以恭维,尤其命令行超级难用,而Linux自己必须得花不少时间在折腾中,更是不适合新手了,Max OS是我认为迄今为止最好用的系统,没有之一, 所以如果你不差钱的话,强烈建议入手一台Mac,推荐Pro系列, 当然它的价格确实比较昂贵,如果暂时入手有困难,推荐以后手头宽裕的时候再入手吧,会带给你质的体验.(Google的工程师们都在用Mac,应该比较有说服力吧

李洪强iOS开发之iOS好文章收集

李洪强iOS开发之iOS好文章收集 该文收集朋友们转发或自己的写的技术文章,如果你也有相关的好文章,欢迎留言,当好文章多的时候,我会对这些好文章进行分门别类 文章 简述 日期 直播服务配置 使用 nginx 和 rtmp 插件搭建视频直播和点播服务器 2015-05-12 20:13:00 iOS9适配技巧 图iOS9适配新技巧 2015-09-29 09:01 TextKit分页效果 图文混排 2015年6月1日 iPhone 6 / 6 Plus 设计·适配方案 屏幕适配 2014-11-2

stormzhang的推荐!

欢迎转载,但请务必在明确位置注明出处!http://stormzhang.com/android/2014/07/07/learn-android-from-rookie/ QQ交流群:入群理由请正确填写我的GitHub账号 * 383323653 (Android学习之路1群,已满) * 187252236 (Android学习之路2群,已满) * 416618703 (Android学习之路3群) 请不要重复加群,谢谢! 不想加群的可以考虑加我的微信公众账号:AndroidDeveloper

Android学习之路(转载)

原文地址:http://stormzhang.github.io/android/2014/07/07/learn-android-from-rookie/ 硬件 电脑–推荐Mac 首先声明我不是果粉,个人Windows,Linux,Mac OX系统均用过, 只能说Windows上面的开发工具简直难以恭维,尤其命令行超级难用,而Linux自己必须得花不少时间在折腾中,更是不适合新手了,Max OS是我认为迄今为止最好用的系统,没有之一, 所以如果你不差钱的话,强烈建议入手一台Mac,推荐Pro系

ios性能测试Instruments

Instruments 用户指南 Instruments用户指南介绍 Instruments 是应用程序用来动态跟踪和分析 Mac OS X 和 iOS 代码的实用工具.这是一个灵活而强大的工具,它让你可以跟踪一个或多个进程,并检查收集的数据.这样,Instruments 可以帮你更好的理解应用程序和操作系统的行为. 使用 Instruments 应用,你可以使用特殊的工具(即 instruments 工具)来跟踪同一进程不同方面的行为.你也可以使用该应用来记录一系列用户界面的动作并响应它们,同