Performance problem

Hi,

I am in the process of optimizing iPhone game, we currently develop and have just ran out of ideas.

The game is 3d shooter, with isometric camera. Test scene consists of level geometry (ground + walls), player character, player weapon and four GuiTexture objects.

Avarage frametime at level of 33-35 ms is way too high, if I want to add more elements to the game.

Device: iPhone 3G
SDK: 3.1.3

Profiler outputs:

----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min:  9.0   max: 13.6   avg: 11.3
cpu-ogles-drv> min:  1.8   max:  3.9   avg:  2.4
cpu-present>   min:  1.2   max:  2.2   avg:  1.4
frametime>     min: 33.2   max: 33.6   avg: 33.5
draw-call #>   min:   9    max:   9    avg:   9     | batched:     0
tris #>        min:  1929  max:  1929  avg:  1929   | batched:     0
verts #>       min:   822  max:   822  avg:   822   | batched:     0
player-detail> physx:  0.5 animation:  0.5 culling  0.8 skinning:  0.6 batching:  0.0 render:  7.3 fixed-update-count: 1 .. 2
mono-scripts>  update:  0.9   fixedUpdate:  0.0 coroutines:  0.0 
mono-memory>   used heap: 278528 allocated heap: 368640  max number of collections: 0 collection total duration:  0.0
----------------------------------------

----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min: 11.4   max: 13.4   avg: 12.5
cpu-ogles-drv> min:  1.7   max:  2.1   avg:  1.9
cpu-present>   min:  1.2   max:  2.4   avg:  1.3
frametime>     min: 33.4   max: 34.6   avg: 33.5
draw-call #>   min:   9    max:   9    avg:   9     | batched:     0
tris #>        min:  1929  max:  1929  avg:  1929   | batched:     0
verts #>       min:   822  max:   822  avg:   822   | batched:     0
player-detail> physx:  0.6 animation:  1.4 culling  0.4 skinning:  1.0 batching:  0.0 render:  5.7 fixed-update-count: 1 .. 1
mono-scripts>  update:  1.9   fixedUpdate:  0.0 coroutines:  0.0 
mono-memory>   used heap: 278528 allocated heap: 368640  max number of collections: 0 collection total duration:  0.0
----------------------------------------

----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min:  9.5   max: 22.9   avg: 13.0
cpu-ogles-drv> min:  1.7   max:  3.4   avg:  2.1
cpu-present>   min:  1.2   max:  1.6   avg:  1.3
frametime>     min: 27.8   max: 56.8   avg: 35.6
draw-call #>   min:   9    max:   9    avg:   9     | batched:     0
tris #>        min:  1929  max:  1929  avg:  1929   | batched:     0
verts #>       min:   822  max:   822  avg:   822   | batched:     0
player-detail> physx:  0.7 animation:  1.0 culling  0.6 skinning:  0.8 batching:  0.0 render:  7.2 fixed-update-count: 1 .. 2
mono-scripts>  update:  1.5   fixedUpdate:  0.0 coroutines:  0.1 
mono-memory>   used heap: 278528 allocated heap: 368640  max number of collections: 0 collection total duration:  0.0
----------------------------------------

Four draw calls come from GuiTextures.
one is from player character (single mesh),
one from player shadow mesh (plane),
one from level ground mesh,
one from level walls mesh,
one from player weapon.

I have no idea where such high frametime comes from.
I don’t use OnGUI and pre-allocate everything (“used heap” statistic doesn’t grow with time).

If you guys have suggestions, what else I could do to increase performanceor what I could have done wrong, please let me know.

Thanks!

I’m not sure how you set your GUI up but you should be able to reduce that to one draw call unless you have a lot of GUI.

Your profiler stats look pretty good. The frametime shows the amount of time per frame which is throttled based on things like vsync. There is a good video where they talk about this a bit from the 2009 unite presentations…

http://unity3d.com/support/resources/unite-presentations/optimizing-for-unity-iphone-1.5

just a guess - maybe have a look in appcontroller.mm, i mean these settings:

#define kFPS 30.0
#define kAccelerometerFrequency 60.0

maybe the “30” is limiting your fps, try to increase it maybe helps?

greets,thomas

And unless you’re using the accelerometer, drop it to 0 aswell.

Thanks for all the answers. I will try to play with these values and add some more gameplay now :slight_smile:

shaKu, thank you for the link. The presentation is great, I can’t believe I missed it.


I am now adding gameplay and profiling the game with more stuff.
From time to time I encounter a lag spike:

If I understand the profiler correctly, cpu-player tells me how much time the game loop spends in Unity Engine. I can’t figure out then, what can cause a spike because player-detail, mono-scripts and mono-memory do not take that long to finish.

Sometimes profiler also shows negative min for cpu-player, anyone know what it means? What’s there, which is not being shown by the profiler?