- Home /
Analyzing iPhone Profiler in Xcode to increase game's performance
I read over the documentation and I realize that some of my numbers seem rather large. I'm trying to optimize as best I can for iPhone 3GS/4. The game runs pretty smooth on iPhone 4S, iPad 3/4 and iPhone 5. I know the older processors don't have nearly the same power but I'm doing my best to optimize my game. Currently the profiler is displaying the following stats. If anyone has some suggestions as to how to increase performance for iPhone 3GS/4 that would be great. I'm trying to wrap my head around how to do this based off of the limited information in the Unity Docs regarding the iPhone Profiler.
iPhone Unity internal profiler stats:
cpu-player> min: 85.8 max: 154.7 avg: 116.9
cpu-ogles-drv> min: 3.2 max: 37.6 avg: 9.0
cpu-waits-gpu> min: 1.2 max: 28.6 avg: 9.1
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 121.1 max: 184.2 avg: 142.4
draw-call #> min: 51 max: 62 avg: 55 | batched: 16
tris #> min: 19415 max: 23390 avg: 21459 | batched: 2147
verts #> min: 22621 max: 27084 avg: 25012 | batched: 1089
player-detail> physx: 28.2 animation: 3.3 culling 0.0 skinning: 0.2 batching: 3.5 render: 13.2 fixed-update-count: 12 .. 19
mono-scripts> update: 13.1 fixedUpdate: 2.7 coroutines: 0.4
mono-memory> used heap: 798720 allocated heap: 1695744 max number of collections: 1 collection total duration: 25.1
Thanks!
Thanks Jake. you brought up a good point about caching component references. I usually do scripts but I'm going to cache everything and see how this works. I already improved performance a little bit by combining some meshes and lowering texture quality but I think the problem lies in the scripting. I just have way too much going on and I'm calling components at runtime like crazy. I'll def cache everything and I'll let you know how it works out :) TY for the tips.
Great comment Jake. Is transform one of the components you cache?
In my projects I cache EVERY component (only if the GO has them, of course). It's unbelievably faster than using GetComponent() every time.
Answer by Jake.OConnor · Dec 11, 2012 at 05:18 AM
I don't have any iPhone specific solutions, so I'm not posting this as an answer, but I'll mention some various ways to increase performance in general.
1) Cache the default component references. Instead of using .animation, .renderer, etc all the time in your scripts, cache a copy of these references to private variables in your Start() or Awake() function. When you use .animation is takes just as long as calling .GetComponent(), which is a long time if you add it up. I had a project running at about 40fps, cashed all those references and it ran at about 130fps w/o any change to functionality.
2) Get rid of any empty Unity functions (Update(), LateUpdate(), etc). Even if empty, they get called and that takes time.
3) Turn off VSync. If you're having terrible screen tearing with VSync off, leave it on, but otherwise leave it off. Depending on the program you can get your fps up by about 500% by turning VSync off (because your program doesn't have to wait for the refresh).
4) Use Coroutines if possible. Not only are they great for functionality, but they allow you to do a lot of things that would eat up a lot of CPU cycles without them. (e.g. Trying to wait for 10 seconds in Update() would require update to be called 10 * fps times, where you could have a coroutine just yield until 10 seconds is up.)
Like I said, these are just some hints to maximize performance on any system.
Your answer
Follow this Question
Related Questions
CPU Usage Question (iOS) 0 Answers
iPhone Performance Question relating to CPU-WAITS-GPU 1 Answer
Call another file of click event of button in iphone 0 Answers
Unity to xCode to iOS device problem 1 Answer
Jumping to high 0 Answers