GC 语言的优化,有什么想法吗? [英] Optimization of a GC language, any ideas?

查看:19
本文介绍了GC 语言的优化,有什么想法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在优化方面,我是一个相当大的新手.在我正在开发的当前游戏中,我设法优化了一个功能并减少了大约 0.5% 的 CPU 负载,这与我一直以来的很棒"一样.

I'm a pretty big newbie when it comes to optimization. In the current game I'm working on I've managed to optimize a function and shave about 0.5% of its CPU load and that's about as 'awesome' as I've been.

我的情况如下:我使用名为 ExEn 的 XNA 包装库在 MonoTouch 中开发了一个物理重度游戏,并尝试尽可能我发现很难让游戏在 iPhone4 上达到可玩的帧率(此时甚至不想考虑 iPhone3GS).

My situation is as follows: I've developed a physics heavy game in MonoTouch using an XNA wrapper library called ExEn and try as I might I've found it very hard to get the game to reach a playable framerate on an iPhone4 (don't even want to think about iPhone3GS at this point).

性能下降几乎肯定是在物理计算中,如果我关闭物理,帧率会急剧上升,如果我禁用所有内容,渲染、输入、音频并且只保留物理性能在物理密集型情况下徘徊在 15fps 左右.

The performance degradation is almost certainly in the physics calculations, if I turn physics off the framerate jumps up sharply, if I disable everything, rendering, input, audio and just leave physics on performance hovers around 15fps during physics intensive situations.

我使用 Instruments 来分析性能,这就是我得到的:http://i.imgur.com/FX25h.png 消耗最多性能的函数要么来自物理引擎 (Farseer),要么来自它们调用的 ExEn XNA 包装函数(特别是 Vector2.Max、Vector2.Min).

I used Instruments to profile the performance and this is what I got: http://i.imgur.com/FX25h.png The functions which drain the most performance are either from the physics engine (Farseer) or the ExEn XNA wrapper functions they call (notably Vector2.Max, Vector2.Min).

我查看了这些函数,我知道 Farseer 可以通过引用将值传递给这些函数,而不是通过值传递值,这样就涵盖了(这实际上是我能想到的唯一方法.这些函数本身基本上非常简单相当于这样的操作

I looked into those functions and I know wherever it can Farseer is passing values by reference into those functions rather than by value so that's that covered (and it's literally the only way I can think of. The functions are very simple themselves basically amounting to such operations as

return new Vector2(Max(v1.x, v2.x), Max(v1.y, v2.y)) 

基本上我觉得我被卡住了,在我有限的能力和对代码优化的理解的情况下,我不确定我的选择是什么,或者我是否还有任何选择(也许我应该蜷缩成胎儿的姿势哭?).随着 LLVM 打开并内置发布,我最多可以获得 15fps.我确实通过降低物理精度设法将游戏提高到 30fps,但这使得许多关卡根本无法玩,因为物体彼此相交并相互折叠.

Basically I feel like I'm stuck and in my limited capacity and understanding of code optimizations I'm not sure what my options are or if I even have any options (maybe I should just curl into a fetal position and cry?). With LLVM turned on and built in release I'm getting maybe 15fps at best. I did manage to bring the game up to 30fps by lowering the physics precision but this makes many levels simply unplayable as bodies intersect one another and collapse in on themselves.

所以我的问题是,这是一个失败的原因还是我可以做些什么来提高性能?

So my question is, is this a lost cause or is there anything I can do to beef up performance?

推荐答案

首先,喜欢你在 Windows Phone 7 上的游戏!

First of all, love your game on Windows Phone 7!

其次,我在您的分析器输出中没有看到任何异常.我曾经对 Farseer 引擎(在 .net 中运行)进行了一次快速而肮脏的性能分析,并得出了类似的结果.看起来您的减速几乎是全面成比例的,可能是由于单声道本身造成的.

Secondly, I don't see anything out of the ordinary in your profiler output. I did a quick and dirty performance analysis of the Farseer engine once (running in .net) and came up with similar results. It almost looks like you have a slowdown that is proportional across the board and may be due to mono itself.

这篇关于GC 语言的优化,有什么想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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