Unity iOS and Android contain a built in profiler. The built-in profiler emits console messages from the game running on device. These messages are written every 30 seconds and will provide insight into how the game is running. Understanding what these messages mean is not always easy, but as a minimum, you should quickly be able to determine if your game is CPU or GPU bound, and if CPU bound whether it’s script code, or perhaps Mono garbage collection that is slowing you down. See later in this page to learn how to configure the built-in profiler.
Here’s an example of the built-in profiler’s output.
iPhone/iPad Unity internal profiler stats:
cpu-player> min: 9.8 max: 24.0 avg: 16.3
cpu-ogles-drv> min: 1.8 max: 8.2 avg: 4.3
cpu-waits-gpu> min: 0.8 max: 1.2 avg: 0.9
cpu-present> min: 1.2 max: 3.9 avg: 1.6
frametime> min: 31.9 max: 37.8 avg: 34.1
draw-call #> min: 4 max: 9 avg: 6 | batched: 10
tris #> min: 3590 max: 4561 avg: 3871 | batched: 3572
verts #> min: 1940 max: 2487 avg: 2104 | batched: 1900
player-detail> physx: 1.2 animation: 1.2 culling: 0.5 skinning: 0.0 batching: 0.2 render: 12.0 fixed-update-count: 1 .. 2
mono-scripts> update: 0.5 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 233472 allocated heap: 548864 max number of collections: 1 collection total duration: 5.7
All times are measured in milliseconds per frame. You can see the minimum, maximum and average times over the last thirty frames.
cpu-player | Displays the time your game spends executing code inside the Unity engine and executing scripts on the CPU. |
cpu-ogles-drv | Displays the time spent executing OpenGL ES driver code on the CPU. Many factors like the number of draw calls, number of internal rendering state changes, the rendering pipeline setup and even the number of processed vertices can have an effect on the driver stats. |
cpu-waits-gpu | Displays the time the CPU is idle while waiting for the GPU to finish rendering. If this number exceeds 2–3 milliseconds then your application is most probably fillrate/GPU processing bound. If this value is too small then the profile skips displaying the value. |
msaa-resolve | The time taken to apply anti-aliasiing. |
cpu-present | The amount of time spent executing the presentRenderbuffer command in OpenGL ES. |
frametime | Represents the overall time of a game frame. Note that iOS hardware is always locked at a 60Hz refresh rate, so you will always get multiples times of 16.7ms (1000ms/60Hz = 16.7ms). |
tris # | Total number of triangles sent for rendering. |
verts # | Total number of vertices sent for rendering. You should keep this number below 10000 if you use only static geometry but if you have lots of skinned geometry then you should keep it much lower. |
batched | Number of draw-calls, triangles and vertices which were automatically batched by the engine. Comparing these numbers with draw-call and triangle totals will give you an idea how well is your scene prepared for batching. Share as many materials as possible among your objects to improve batching. |
The player-detail section provides a detailed breakdown of what is happening inside the engine:-
physx | Time spent on physics. |
animation | Time spent animating bones. |
culling | Time spent culling objects outside the camera frustum. |
skinning | Time spent applying animations to skinned meshes. |
batching | Time spent batching geometry. Batching dynamic geometry is considerably more expensive than batching static geometry. |
render | Time spent rendering visible objects. |
fixed-update-count | Minimum and maximum number of FixedUpdates executed during this frame. Too many FixedUpdates will deteriorate performance considerably. |
The mono-scripts section provides a detailed breakdown of the time spent executing code in the Mono runtime:
update | Total time spent executing all Update() functions in scripts. |
fixedUpdate | Total time spent executing all FixedUpdate() functions in scripts. |
coroutines | Time spent inside script coroutines. |
The mono-memory section gives you an idea of how memory is being managed by the Mono garbage collector:
allocated heap | Total amount of memory available for allocations. A garbage collection will be triggered if there is not enough memory left in the heap for a given allocation. If there is still not enough free memory even after the collection then the allocated heap will grow in size. |
used heap | The portion of the allocated heap which is currently used up by objects. Every time you create a new class instance (not a struct) this number will grow until the next garbage collection. |
max number of collections | Number of garbage collection passes during the last 30 frames. |
collection total duration | Total time (in milliseconds) of all garbage collection passes that have happened during the last 30 frames. |
On iOS, it’s disabled by default. To enable it, open the Unity-generated XCode project, select the InternalProfiler.h
file, and change the line
#define ENABLE_INTERNAL_PROFILER 0
to
#define ENABLE_INTERNAL_PROFILER 1
Select View > Debug Area > Activate Console in the XCode menu to display the output console (GDB) and then run your project. Unity will output statistics to the console window every thirty frames.
To enable it on Android, click the Enable Internal Profiler checkbox in PlayerSettings (Edit > Project Settings > Player). Make sure Development Build is checked in the Build Settings when building, and the statistics should show up in logcat when run on the device. To view logcat, you need adb or the Android Debug Bridge. Once you have that, simply run the shell command adb logcat.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.