GC语言的优化,有什么想法吗?

Optimization of a GC language, any ideas?(GC语言的优化,有什么想法吗?)
本文介绍了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语言的优化,有什么想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)