问题描述
要清楚,这是一个正常的iPhone应用程序,而不是一个游戏。
我已经阅读了几次网上一些开发人员提到他们正在努力改善/减少他们的应用程序的启动时间,但从来没有如何这样做的任何好的背景信息。
所以问题很简单:怎么可以
与任何其他性能问题相同:使用Shark和/或Instruments来识别iPhone应用程序的瓶颈你的代码,然后专注于如何加快速度。每个工具都会提供一张图片,告诉你在代码的哪些部分花费了多少时间,所以一般的方案是在启动应用程序时运行该工具,然后查看数据以查看性能命中的发生位置。 / p>
在应用程序启动时,最有可能改进的是推迟数据加载,直到后来实际需要的时候,不同地描述为按需或延迟加载。基本上,在应用启动时不要加载任何数据,除非应用加载时实际需要。 实际上,在应用程式启动时,可能需要某些时候 的许多资料不必立即可用。例如,如果您有一个包含N条记录的数据库,但每次只能看到一条记录,则不要在应用程序启动时将所有N记录到内存中。加载当前记录的任何内容,然后在实际需要时加载其他内容。
To be clear, this is for a normal iPhone application, and not a game.
I've read around the web a few times some developers mentioning that they were working hard to improve/reduce the startup time of their applications, but never with any good background information on how to do so.
So the question is simple: how can you reduce the startup of iPhone applications?
Same as any other performance issue: Use Shark and/or Instruments to identify bottlenecks in your code, and then focus on how you can speed things up there. Each tool will give you a picture of how much time was spent in what parts of your code, so the general scheme would be to run the tool while you start the app and then pore over the data to see where the performance hits occur.
At app startup time, the most likely candidates for improvement will be deferring data loading until later on when it's actually needed, variously described as "on demand" or "lazy" loading. Essentially, don't load any data at app startup unless it's actually needed right away when the app loads. In practice, lots of stuff that may be needed at some point doesn't have to be immediately available when the app starts. For example, if you have a database of N records but only one is visible at a time, don't load all N into memory at app startup time. Load whatever the current record is and then load the others when you actually need them.
这篇关于如何减少典型iPhone应用程序的启动时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!