Android移动开发性能与可扩展性
我正在android中开发一个游戏,我一直在考虑将游戏的许多元素(例如游戏对象)细分为单独的类和子类。但我知道对这些对象的方法调用会导致一些开销。提高性能更好还是提高可扩展性更好?
im developing a game in android, and i've been thinking about subdividing many of the elements of the game (e.g. game objects) into separate classes and sub-classes. but i know that method calls to these objects will cause some overhead. would it be better to improve performance or to improve extensibility?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只有您才能回答这个问题 - 有些游戏需要最高的性能,而另一些游戏则变得非常复杂,以至于易于扩展是唯一的出路。
但请记住,您所指的“开销”可能非常小 - 几乎无穷小 - 并且不应该在您对任何初始版本的关注列表中占据很高的位置。
还要记住,以后提取性能总是更容易,但可扩展性却不能这么说。
最后,请注意,过早的性能调整经常会失败。很难预测性能瓶颈在哪里,现场测试更有可能产生良好的结果。
Only you can answer that question - some games require the utmost in performance, others become so complex that ease of extensibility is the only way to go.
Bear in mind though that the 'overhead' you're referring to is likely to be VERY small - nearly infinitesimal - and should not be high on your list of concerns for any initial release.
Remember too that it's always easier to extract performance later, the same can not be said of extensibility.
Finally, note that premature performance tweaks frequently fail. Ascertaining where the performance bottlenecks are can seldom be predicted, testing in situ is far more like to yield good results.
您考虑过内联函数吗?这样您就可以保持代码的可扩展性和清晰性,理想情况下不会造成性能损失。
Have you considered inline functions? That way you may preserve extensibility and clearness of code, ideally without a performance loss.
首先以最优雅的方式构建。
最后优化瓶颈,保持其余部分完好无损。
At first just build in the most elegant way.
At last optimize the bottlenecks leaving the rest intact.