Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Measure performance with the built-in profiler

Use and configure the built-in profiler for iOS.
Read time 5 minutesLast updated 13 days ago

Note
The internal profiler is deprecated and will be retired in a future version of Unity. Use the Profiler window instead (menu: Window > Analysis > Profiler) Refer to Collecting performance data on an iOS device for more information on how to profile iOS devices.
Unity contains a built-in profiler for iOS to provide insight on how the application is running. Every 30 frames, the built-in profiler emits console messages from the application running on the device to help determine if it's CPU or GPU-bound. If your application is CPU-bound, you can determine whether script code or garbage collection is causing the bottleneck.
Here's an example of the built-in profiler's output:
iPhone Unity internal profiler statsframetime> min: 32.5 max: 34.1 avg: 33.3cpu-player> min: 2.2 max: 4.4 avg: 3.7batches> min: 3 max: 3 avg: 3draw calls> min: 3 max: 3 avg: 3tris> min: 1704 max: 1704 avg: 1704verts> min: 5088 max: 5088 avg: 5088dynamic batching> batched draw calls: 0 batches: 0 tris: 0 verts: 0static batching> batched draw calls: 0 batches: 0 tris: 0 verts: 0player-detail> physx: 0.0 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: 0.0 fixed-update-count: 0 .. 0scripting-scripts> update: 0.0 fixedUpdate: 0.0 coroutines: 0.0 scripting-memory> information not available on non-development player configuration
All times are measured in milliseconds per frame. You can check the minimum, maximum, and average times over the last thirty frames.

General CPU activity

Property

Function

cpu-playerDisplays the time your app spends executing code inside the Unity engine and executing scripts on the CPU.
cpu-ogles-drv (Android only)Displays the time spent executing OpenGL ES driver code on the CPU. These driver stats can be affected by several factors, including the number of draw calls, number of internal rendering state changes, rendering pipeline setup, and number of processed vertices.
cpu-present (Android only)The amount of time spent executing the
presentRenderbuffer
command in OpenGL ES.
frametimeRepresents the overall time of an app frame. Note that iOS hardware is locked at a 60Hz refresh rate, so this property will always return a time that's a multiple of 16.7ms (1000ms/60Hz = 16.7ms).

Rendering statistics

Property

Function

tris #Total number of triangles sent for rendering.
verts #Total number of vertices sent for rendering. Keep this number under 10000 if your application uses only static geometry. If your application uses many instances of skinned geometry, this number should be much lower.
dynamic/static batchingNumber of draw-calls, triangles, and vertices that the engine automatically batched. Comparing these numbers with draw-call and triangle totals can give you an idea how well is your scene prepared for batching. Share as many materials as possible among your objects to improve batching.

Detailed Unity Player statistics

The player-detail section provides a detailed breakdown of what's happening inside the engine:

Property

Function

physxTime spent on physics.
animationTime spent animating bones.
cullingTime spent culling objects outside the camera frustum.
skinningTime spent applying animations to skinned meshes.
batchingTime spent batching geometry. Batching dynamic geometry is considerably more resource-intensive than batching static geometry.
renderTime spent rendering visible objects.
fixed-update-countMinimum and maximum number of FixedUpdates executed during this frame. Too many FixedUpdates will deteriorate performance considerably.

Detailed script statistics

The scripting-scripts section provides a detailed breakdown of the time spent executing code in the Mono runtime:

Property

Function

updateTotal time spent executing all
Update()
methods in scripts.
fixedUpdateTotal time spent executing all
FixedUpdate()
methods in scripts.
coroutinesTime spent inside script coroutines.

Detailed statistics on memory allocated by scripts

The scripting-memory section gives you an idea of how memory is managed by the Mono garbage collector:

Property:

Function:

allocated heapTotal amount of memory available for allocations. A garbage collection triggers if the heap doesn't have enough memory left for a given allocation. If this doesn't free enough memory, the allocated heap will grow in size.
used heapThe 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 grows until the next garbage collection.
max number of collectionsNumber of garbage collection passes during the last 30 frames.
collection total durationTotal time (in milliseconds) of all garbage collection passes that happened during the last 30 frames.

Configuration

On iOS, the internal profiler is disabled by default. To enable it, use either of the following processes.

Xcode project

To enable the internal profiler from inside the Xcode project, use the following steps:
  1. Open the Unity-generated Xcode project,
  2. Select the
    InternalProfiler.h
    file.
  3. Update the following line from:
#define ENABLE_INTERNAL_PROFILER 0
to
#define ENABLE_INTERNAL_PROFILER 1

Player settings

To enable the internal profiler in Unity, use the following steps:
  1. In the main menu, go to Edit >
    Project Settings

    ?

    >
    Player Settings

    ?

    > iOS.
  2. In the Debugging and crash reporting section, enable Enable Internal Profiler (Deprecated).
Note
Ensure that the
Development Build

?

option is enabled in the Platform Settings section of the Build Profiles window when you build your application.

Display the console

To display the output console, in Xcode select View > Debug Area > Activate Console and then run your project. Unity outputs statistics to the console window every 30 frames.