简体   繁体   English

从Bundle或磁盘加载更好吗?

[英]Is it better to load from Bundle or disk?

I have about 10 images in my app. 我的应用程序中大约有10张图片。 They are in the bundle as resources. 它们作为资源捆绑在一起。 Is it better to load them from the bundle on each app start? 在每个应用程序启动时从捆绑中加载它们是否更好? Or deploy them to disk once and always load from disk? 还是将它们部署到磁盘一次并始终从磁盘加载?

I think this might be a little premature optimizing… 我认为这可能有些过早的优化…

Is your app slow now? 您的应用现在慢了吗?

At some point the images are coming off the disk, no matter what. 无论何时,映像都会从磁盘上脱落。 If it really becomes an issue, you can implement both solutions and benchmark them with instruments. 如果确实成为问题,则既可以实施解决方案,也可以使用工具对其进行基准测试。

I have built several apps with images and haven't even thought of this. 我用图像构建了多个应用程序,甚至都没有想到这一点。 I assume the difference in performance would be negligible, since, as I said, they come off disk either way. 我认为性能上的差异可以忽略不计,因为正如我所说,它们都是从磁盘上脱落的。

I think the best thing to do would be to mark this down in your code as a possible optimization and just go with what you have now. 我认为最好的办法是在代码中将此标记为可能的优化,然后继续使用您现在拥有的功能。 When you start beta testing, if speed becomes an issue, you can try it then. 开始Beta测试时,如果速度成为问题,则可以尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM