减少 iPhone 应用程序启动时间

发布于 2024-10-03 15:23:12 字数 315 浏览 0 评论 0原文

我正在尝试调查我的应用程序的启动时间很长,并且需要一些帮助。启动大约需要 6-7 秒,这实在是太长了。我没有加载任何数据集或任何东西,但该应用程序是一个计算器,所以我的 xib 确实有很多按钮和按钮图像。

我想使用 Instruments (或其他东西)来分析所有时间都花在哪里,以便我可以优化,但是 Instruments 的文档并没有真正给我太多关于如何将其用于此特定的细节问题和/或如何解释结果。

您对如何测试这个有什么建议吗?有关如何使用 Instruments 实现此目的的教程的指针? iTunes U 视频还是其他?

欢迎任何建议!

肯尼

I'm trying to investigate a very long start up time for my app and could use some help. It takes about 6-7 seconds to start up and that's just FAR too long. I'm not loading any data sets or anything, but the app is a calculator so my xib does have lots of buttons and button images.

I'd like to use Instruments (or something else) to analyze where all of the time is being spent so that I can optimize, but the documentation for Instruments isn't really giving me much on specifics of how to use it for this specific problem and/or how to interpret the results.

Do you have any suggestions for how to test this? A pointer to a tutorial on how to use Instruments for this? An iTunes U video or something else?

Any suggestions are welcome!

Kenny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

帅的被狗咬 2024-10-10 15:23:12

帕利蒙多问我最终是如何解决我的问题的……这是一堆小改变,我不太确定节省的费用在哪里发挥作用,我将在下面解释原因。

我的应用程序是一个计算器,所以它有很多按钮。我一开始以为一定是按钮加载导致了问题,但正如我在上面的评论中向 Paul 解释的那样,即使我加载了 0 个按钮,也只会缩短 1 秒的启动时间。在改变了许多小事情之后,我能够节省 3 秒的启动时间,这已经足够好了。

我有一个背景图像,它是一个漂亮的纹理渐变图像。我减小了文件大小(更改了纹理,使用不同的选项导出)。

我从预先加载 100 个按钮(这是一个计算器)改为加载大约 15 个按钮,但尝试以秘密方式进行,这样用户就不会注意到。大约 50 个按钮无论如何都无法启动,因为您必须点击 Shift 按钮才能看到它们,因此它们很容易延迟加载。其他的都是可见的,但我认为用户不会在启动时点击其中的大部分,因为他们需要先点击一些数字。因此,我将所有数字键盘按钮和清除按钮保留在 xib 中,以便在启动时加载它们,但从 xib 中删除了其他所有内容。

这在屏幕上留下了一个很大的空白区域,当我延迟加载它们时,您实际上可以看到按钮填充了空白区域(填充速度非常快,但您可以看到空白区域,然后所有按钮都出现)。因此,我更新了背景渐变图形以包含按钮的图像。这些按钮似乎在那里,但实际上并不在那里,因此除非用户在 2 秒内点击了一个假按钮,否则他们永远不会注意到问题......通常他们只是尝试再次点击该按钮,到那时它通常已经出现了延迟加载,因此有效。

Palimondo asked how I eventually solved my problem... it was a bunch of small changes and I'm not truly sure where the savings came in to play and I'll explain why below.

My app is a calculator, so it has a ton of buttons. I thought at first it must be the button loading causing the problem, but as I explained in the comments above to Paul, even if I loaded 0 buttons, that only shaved 1 second off of the start up time. After changing many small things, I was able to save 3 seconds off of start up time which was good enough.

I had a background image that was a nice textured-gradient-ish image. I reduced the file size on it (changed the texture, exported it with different options).

I went from loading 100 buttons up front (it's a calculator) to loading about 15, but attempted to do it in a secret fashion so the user wouldn't notice. About 50 of the buttons aren't visible to start anyway because you have to tap a Shift button to see them, so they were easy to lazy-load. The others are visible, but I figured that the user isn't going to tap most of those right at start-up because they need to hit some numbers first. So I left all of the number pad buttons and the Clear button in the xib so they are loaded on start up but removed everything else from the xib.

That left me with a big blank area on the screen and you could actually see the buttons filling in the blank area as I lazy loaded them (filling very quickly, but you could see the blank area and then all the buttons appear). So I updated the background gradient graphic to include images of the buttons. The buttons appear to be there, but they aren't, so unless the user taps a fake button within 2 seconds they never notice a problem... and usually they just try to tap that button again anyway and by then it usually has been lazy-loaded and therefore works.

沩ん囻菔务 2024-10-10 15:23:12

在执行上述任何建议之前:

从 XCode 运行时是否需要 6-7 秒?或者直接在 iPhone 上点击启动?

调试器和工具在这里不会给您带来太大帮助,因为它们只会增加开销,并且在分析方面不会有太大帮助,因为它会破坏您将看到的数据。

编辑:

在分析工具方面,您可能需要考虑使用 Shark:
http://www.switchonthecode.com/tutorials /using-shark-to-performance-tune-your-iphone-app

一般来说,使用起来非常简单。这是不言自明的。

Before doing any of the above suggestions:

Is this 6-7 seconds while running from XCode? Or from starting directly by tapping it on the iPhone?

Debuggers and instruments won't help you much here, since they just add to the overhead, and won't help as much in profiling because it poisons the data you'll see.

Edit:

In terms of profiling tools, you may want to look into using Shark:
http://www.switchonthecode.com/tutorials/using-shark-to-performance-tune-your-iphone-app

It's pretty simple to use in general. It's sorta self-explanatory.

猫性小仙女 2024-10-10 15:23:12

这里有一些建议:

  • 您需要立即加载所有这些按钮吗?
  • 您是否(过度)在图像中使用透明胶片?
  • 图像的尺寸是否符合要求?拉伸(调整大小)需要时间来计算
  • 您是否执行了任何阻塞主线程的操作?

Here are couple of suggestions:

  • do you need all those buttons loading up at once?
  • do you (over)use transparencies in your images?
  • are the images the exact size required? Stretching (resizing) takes time to compute
  • do you perform any operation that is blocking the main thread?
清旖 2024-10-10 15:23:12

我将测量实际设备上空虚拟应用程序(可能是基于 XCode 窗口的应用程序模板)的启动时间(调试器已断开连接)。然后开始将应用程序中的初始化代码、视图和对象添加到这个虚拟应用程序中,直到找到最慢启动时间的因素。

I would measure the startup time of an empty dummy app (maybe the XCode Window-based app template) on your actual device (debugger disconnected). Then start adding your initialization code, views and objects from your app into this dummy app until you find what's slowing the startup time the most.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文