分析和优化游戏的Andr​​oid [英] Profiling and Optimizing a game android

查看:154
本文介绍了分析和优化游戏的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做这将是使用OpenGL ES的一个3D街机十岁上下的游戏我的第一的Andr​​oid游戏。我一直工作在它相当长的时间,主要是优化了发动机的灵活性的未来。

I'm making my first Android game which is going to be a 3D arcade-ish game using opengl es. I've been working on it for quite a long time, mainly optimizing the engine for flexibility for the future.

反正我现在完全的游戏功能和所有的pretty的东西做的,但它laggs对不在我的手机调试手机。游戏中有pretty高品质的图形为手机游戏那么一点点LAGG的预期,但在运行在Nexus S的游戏,并在4G的myTouch运行它之间的性能差异是巨大的。本场比赛是不是在低端手机一样LG擎天柱甚至可玩(游戏运行,但它太波涛汹涌舒舒服服玩)。在我的Nexus SI很少,如果得到的起伏动作(我实现了帧速率在游戏中独立运动),但在4G的myTouch是很多比较常见的,虽然游戏仍然可玩....但恼人

Anyways now I'm completely done with the games features and all the pretty stuff, but it laggs on phones that AREN'T my debug phone. The game has pretty high-quality graphics for a mobile game so a little lagg is expected, but the difference in performance between running the game on a Nexus S and running it on a MyTouch 4G is huge. The game isn't even playable on lower-end phones like the LG Optimus(the game runs, but its too choppy to play comfortably). On my Nexus S I rarely if ever get choppy movement(I've implemented frame-rate independent movement in the game) but on the MyTouch 4G it is a lot more common, although the game is still playable....but annoying

我来自一个桌面游戏开发背景,以及优化前从未受到对我的兴趣。您有什么建议可以帮我加快游戏?

I come from a desktop game-development background, and optimization has never been subject of interest for me before. What can you recommend to help me speed up the game?

我试过优化code像我可能可以,而且性能也显著改善,但似乎有一些事情,我已经错过了,或者我可以俯瞰。它具有完整的发动机和许许多多code的。一个巨大的游戏

I've tried optimizing code as much as I possibly could, and the performance has improved significantly, but there seem to be some things that I've missed or am overlooking. Its a huge game with a full engine and lots and lots of code.

我试过追踪所有分配,并确保他们不会释放或运行期间遗忘,这样当你在玩的GC不会被调用。这就是基本上所有我能想到的做,我不知道还有什么可以使它LAGG

I've tried tracking down all allocations and making sure they aren't deallocated or forgotten during runtime so that the GC doesn't get invoked while you are playing. Thats basically all I can think of doing, I don't know what else could make it lagg

我怀疑它的网格的多边形数量,因为即使他们是高品质的,我说在游戏中,让你选择显卡从低,中质量的选项,高级很像电脑游戏和低和高之间的差异则介于600-900之间的顶点!我注意到,让唯一的改进是加载时间。也没有任何特殊的后处理效果,灯光,渲染,实时SSS,或任何。只是质感的面孔:P

And I doubt its the poly count of the meshes because even though they are high quality, I added an option in the game that lets you choose the quality of the graphics from Low, Medium, and High much like on a computer game, and the difference between Low and High are somewhere between 600-900 vertices! The only improvement I've noticed that gives is load time. Also there aren't any special post-processing effects, lighting, shaders, realtime SSS, or any of that. Just textured faces :P

也是LAGG我reffering到是随机冻结。我是pretty确保他们的GC,但它可能是别的东西,因为我的认为的我发现和控制的所有分配(有很多)。由于我的游戏帧速率无关,无论何时解冻,玩家和敌人和一切向前跳跟上,这使得本已艰难的比赛困难得多!

also the "lagg" I'm reffering to are random freezes. I'm pretty sure they are the GC, but it could be something else since I think I've found and controlled all allocations(there are a lot). Since my game is frame-rate independent, whenever it unfreezes, the player and enemies and everything 'jumps forward' to keep up, and this makes an already difficult game a LOT more difficult!

我是新来分析和优化。如何使用Android的调试工具(或其他第三方工具),以获得我的游戏运行时如何执行,以及何时/为什么冻结,这样我可以修复他们更好的图片。

I'm new to profiling, and optimization. How can I use the android debug tools(or other third-party tools) to get a better picture of how my game performs during runtime, and when/why it freezes so that I can fix them.

另外,奖金的问题:):是有我的方式来看看它是如何将在其他手机而无需实际的电话或知道谁拥有它们的人执行?就像,如何快速将它去一个Droid X的,即使我没有Droid X的也没有我认识的人

ALSO, bonus question :) : is there a way for me to see how it would perform on other phones without actually having the phones or knowing people who have them? Like, how fast would it go on a Droid X even though I don't have a Droid X nor does anyone I know

推荐答案

你试过分析了code。与traceview?
插入

Have you tried profiling the code with traceview? insert

Debug.startMethodTracing("myfile");

在的onCreate,然后

in onCreate, then

Debug.stopMethodTracing();

您希望它完成写入文件。要查看结果,将设备插入计算机并运行:

where you want it to finish writing the file. To view the results, plug the device into the computer and run:

/path/to/android-sdk/platform-tools/adb pull /sdcard/myfile.trace
/path/to/android-sdk/tools/traceview ./myfile.trace

这将显示哪些类是花更多的时间。您可以优化慢班,和/或移动到后台线程。

This will show what classes are taking more time. You may be able to optimize the slower classes, and/or move it to a background thread.

您提到它的一些手机工作得很好,也许是那些与24MB /应用的限制,而不是16MB /程序限制较新的手机?您可以尝试在Eclipse的内存分析,检查内存泄漏或不必要的大对象。要安装,转到帮助 - >安装软件,并使用

You mentioned it works fine in some phones, perhaps those are the newer phones with 24mb/app limit instead of 16mb/app limit? You might try the Memory Analyzer in Eclipse, to check for memory leaks or unnecessary large objects. To install, go to Help -> Install Software, and use

http://download.eclipse.org/mat/1.1/update-site/

然后,当你在DDMS视图中选择转储HPROF文件(绿色玻璃用红色箭头)调试,它应该打开存储分析仪。

Then, while you are debugging in DDMS view, select Dump HPROF File (The green glass with the red arrow), it should open the memory analyzer.

编辑 -

看来你需要将Android的HPROF文件现在转换,因为这里描述

It seems you need to convert the Android-hprof file now, as described here.

这篇关于分析和优化游戏的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆