Version: 2018.2
Profiler window
Área de Renderización(Rendering Area)

Área de Uso del CPU(CPU Usage Area)

El área de Uso del CPU muestra dónde el tiempo es gastado en su juego. Cuando es seleccionado, el panel inferior muestra información jerárquica de tiempo para el frame seleccionado.

  • Modo Jerárquico: Muestra información jerárquica de tiempo.
  • Group Hierarchy mode: Groups time data into logical groups (such as Rendering, Physics, Scripts). Because children of any group can also be in different groups (for example, some scripts might also call rendering functions), the percentages of group times often add up to more than 100%.

Drag chart labels up and down to reorder the way the CPU chart is stacked.

Seleccionando Items Individuales

Cuando un ítem es seleccionado en el panel inferior, su contribución a la gráfica del CPU es subrayada (y el resto se atenúan). Haciendo click en el elemento ítem lo de-selecciona.

Render.OpaqueGeometry is selected and its contribution is highlighted in the chart
Render.OpaqueGeometry is selected and its contribution is highlighted in the chart

En la información jerárquica de tiempo, el tiempo de uno mismo (self time) se refiere a la cantidad de tiempo gastado en una función en particular no incluyendo el tiempo gastado llamando sub-funciones. En la foto de pantalla de arriba, pro ejemplo 41.1% del tiempo es gastado en la función Camera.Render. Esta función hace mucho trabajo y llama varias funciones de dibujo y de culling. Excluyendo todas estas funciones solo un 2.1% del tiempo es gastado en la función Camera.Render. Las columnas Time ms y Self ms muestran la misma información, pero presentada en mili-segundos. Por lo que, Camera.Render toma solo 0.01ms, pero incluyendo todas las funciones que llama, 0.21 ms son consumidos. La columna GC Alloc muestra qué tanta memoria ha sido asignada en el frame actual, el cual será coleccionado después por el recolector de basura (garbage collector). Al diseñar su código para mantener este valor en cero, usted puede evitar que el Garbage Collector (recolector de basura) de causar contratiempos en su framerate (velocidad de frames).

The Time ms and Self ms columns show the same information but in milliseconds. Camera.Render takes 0.01ms but, including all the functions it calls, 0.21ms are consumed. The GC Alloc column shows how much memory has been allocated in the current frame, which is later collected by the garbage collector. Keep this value at zero to prevent the garbage collector from causing hiccups in your framerate.

The Others section of the CPU profiler records the total of all areas that do not fall into Rendering, Scripts, Physics, Garbage Collection or VSync. This includes Animation, AI, Audio, Particles, Networking, Loading, and PlayerLoop.

Physics Markers (Marcadores de física)

The descriptions below provide a brief account of what each of the various high-level Physics Profiler markers mean.

  • Physics.Simulate: Llamado desde FixedUpdate. Esto actualiza el estado actual de física al instruir PhysX en correr su simulación.
  • Physics.Processing: Llamado desde FixedUpdate. Esto es dónde todos los trabajos de física sin-cloths son procesados. Expandiendo este marcador va a mostrar un detalle de bajo nivel del trabajo que se está haciendo internamente en PhysX.
  • Physics.ProcessingCloth: Llamado desde FixedUpdate. Esto es dónde todos los trabajos de física de cloth son procesados. Expandiendo este marcador va a mostrar un detalle de bajonivel del trabajo que se está haciendo internamente en PhysX.
  • Physics.FetchResults: Llamado desde FixedUpdate. Esto es dónde los resultados de la simulación de física son colectados desde PhysX.
  • Physics.UpdateBodies: Llamado desde FixedUpdate. Esto es dónde todos los cuerpos de física tienen sus posiciones y rotaciones actualizadas al igual que dónde los mensajes que comunican estas actualizaciones son enviados.
  • Physics.ProcessReports: Llamado desde FixedUpdate. Este escenario es ejecutado una vez que el fixed update de física haya concluido y es dónde todos los varios escenarios de la respuesta de los resultados de la simulación son procesados. Los Contactos, rupturas de articulaciones y triggers son actualizados e informados aquí. Hay cuatro sub-escenarios distintos:
    • Physics.TriggerEnterExits: Llamado desde FixedUpdate. Aquí es dónde los eventos OnTriggerEnter y OnTriggerExit son procesados.
    • Physics.TriggerStays: Llamado desde FixedUpdate. Aquí es dónde eventos OnTriggerStay son procesados.
    • Physics.Contacts: Llamado desde FixedUpdate. Aquí es dónde los eventos OnCollisionEnter, OnCollisionExit y OnCollisionStay son procesados.
    • Physics.JointBreaks: Llamado desde FixedUpdate. Aquí es dónde las actualizaciones y mensajes relacionados a articulaciones (joints) siendo rotas es son procesados.
  • Physics.UpdateCloth: Llamado desde Update. Aquí es dónde actualizaciones relacionadas a Cloth y sus skinned meshes son hechos.
  • Physics.Interpolation: Llamado desde Update. Este escenario trata con la interpolación de posiciones y rotaciones para todos los objetos de física.

Advertencias de Rendimiento

There are some common performance issues the CPU Profiler is able to detect and warn you about. These appear in the Warning column of the lower pane when viewing the CPU Usage.

A Profiler warning indicating that Static Colliders have been moved
A Profiler warning indicating that Static Colliders have been moved

Los problemas específicos que el profiler puede detectar son:

  • Rigidbody.SetKinematic [Re-create non-convex MeshCollider for Rigidbody]
  • Animation.DestroyAnimationClip [Triggers RebuildInternalState]
  • Animation.AddClip [Triggers RebuildInternalState]
  • Animation.RemoveClip [Triggers RebuildInternalState]
  • Animation.Clone [Triggers RebuildInternalState]
  • Animation.Deactivate [Triggers RebuildInternalState]

In the screenshot above, the Profiler is showing the Static Collider.Move warning. The Warning column shows that this warning has been triggered 12 times in the current frame. The term “delayed cost” means that, although the entry in the Profiler may show a low cost (in this case 0.00ms), the action may trigger more system-demanding operations later on.

CPU Profiler Timeline

Mem Record: Native memory performance profiling

Native memory performance profiling allows you to profile activity inside Unity’s native memory management system and assess how it is affecting runtime performance. This can be useful when searching for unwanted or resource-intensive allocation patterns in Unity’s memory management.

To profile Unity’s native memory management, you need to record it. To access native memory recording mode (called Mem Record in Unity), go to Window > Analysis > Profiler to open the Profiler window. Select the CPU Usage Profiler (if it is not visible, click Add Profiler > CPU) then the drop-down menu underneath the Profiler. Next, click Timeline and then select Mem Record.

Selecting recording mode
Selecting recording mode
Option Función: Impact on performance
None Mode disabled. This is the default selection. N/A
Sample only Records memory allocations, re-allocations, de-allocations, activity type, and system. Low
Callstack (fast) This has the same functionality as Sample only, but also records a shortened callstack from the native allocation site to where the callstack transitions from native symbols into script symbols. Effectively, you can only see the callstack up to the deepest script symbol. Medio
Callstack (full) This has the same functionality as Sample only, but also records the callstack with full script-to-native and native-to-script transitions. Alto

Note: When the active Profiler is only connected to a standalone player, only the low-impact Sample only mode is supported.

The recorded memory allocation samples appear in the Profiler window in bright red.

Click the High Detail button next to Mem Record to enable High Detail mode. Select a sample to display the allocation type and system. If the callstack was recorded for the selected allocation sample, the associated callstack symbols are resolved and displayed as well:

Using Mem Record

There are a number of instances where the Mem Record function is useful. For example:

  • Learning when a system is doing many small allocations instead of just a few large ones.
  • Learning when a Worker Thread accidentally allocates memory (for example by unintended MemLabel use).
  • Finding lock contention (when several threads try to access the native memory system simultaneously).
  • Finding sources of memory fragmentation (particularly important for low-memory devices).

High Detail view of Timeline

The High Detail view for the CPU Usage Profiler Timeline gives at least one pixel of width to every time sample recorded by Unity’s CPU Usage Profiler.

This allows you to see a complete overview of all activity in a frame, including short-lived activities such as thread synchronization or memory allocation.

To enable the High Detail view, go to Window > Analysis > Profiler to open the Profiler window. Select the CPU Usage Profiler (if it is not visible, click Add Profiler > CPU) then select the drop-down menu underneath the Profiler and click Timeline followed by High Detail.

Comparison

The following two images show the difference between the High Detail view and the normal view for the CPU Usage Profiler’s Timeline.

High Detail view

Normal view

Profiler window
Área de Renderización(Rendering Area)