Version: 2019.1
Profiler overview
Área de Uso del CPU(CPU Usage Area)

Profiler window

Access the Profiler window in the Unity Editor via the toolbar: Window > Analysis > Profiler.

See Profiler overview for a summary of how the Profiler works.

Profile window
Profile window

Profiler Controls

The Profiler controls are in the toolbar at the top of the window. Use these to turn profiling on and off, and navigate through profiled frames. The transport controls are at the far right end of the toolbar. Note that when the game is running and the profiler is collecting data, clicking on any of these transport controls pauses the game. The controls go to the first recorded frame, step one frame back, step one frame forward and go to the last frame respectively.

The Profiler does not keep all recorded frames, so the notion of the first frame should really be though of as the oldest frame that is still kept in memory. The “current” transport button causes the profile statistics window to display data collected in real-time. The Active Profiler popup menu allows you to select whether profiling should be done in the editor or a separate player (for example, a game running on an attached iOS device). Save button lets you write the recorded frames to a file. Correspondingly, Load button reads data saved earlier. You can also load a binary profile data written out by the player (when generating log, set Profiler.enableBinaryLog to enable binary format). If “Load” is clicked while the shift button is pressed, file contents is appended to the current profile frames in memory.

Perfilamiento Profundo (Deep Profiling)

Cuando prenda Deep Profile, todo su código script es perfilado - eso es, todas las funciones llamadas son grabadas. Esto es útil para saber exactamente dónde se está gastando más tiempo en el código de su juego.

Tenga en cuenta que Deep Profiling incurre una gran sobrecarga y usa mucha memoria, y como un resultado su juego va a correr significantemente más lento mientras esté perfilando(profiling). Si usted está usando un código script complejo, el Deep Profiling puede que no sea para nada posible. Deep Profiling debería trabajar lo suficientemente rápido para juegos pequeños con un scripting simple. Si usted encuentra que Deep Profiling su juego entero causa la velocidad de frames caer lo suficiente para que su juego apenas corra, usted debería considerar no usar este acercamiento, y más bien utilizar el acercamiento descrito abajo. Usted puede encontrar Deep Profiling más útil mientras usted esté diseñando su juego y decidiendo cómo es la mejor manera de implementar las características claves. Tenga en cuenta que para juegos grandes Deep Profiling puede causar que Unity se quede sin memoria y por esta razón deep profiling puede no ser posible.

Manually profiling blocks of your script code will have a smaller overhead than using Deep Profiling. Use Profiler.BeginSample and Profiler.EndSample scripting functions to enable and disable profiling around sections of code.

Color Blind Mode

Location of color blind mode The Profiler window features a Color Blind Mode, which uses higher contrast colors in the graphs to enhance visibility for users with red-green color blindness (such as deuteranopia, protanopia, or tritanopia). To enable it, click the context menu in the upper-right corner of the Profiler window, and click Color Blind Mode.

Mirar el Tiempo de Sincronización

Cuando se corra a una velocidad de cuadro fija o se corra en una sincronización con el vertical blank, Unity graba el tiempo de espera en “Wait For Target FPS”. Por defecto esta cantidad de tiempo no es mostrada en el perfilador. Para ver cuánto tiempo se gasta esperando, usted puede activar “View SyncTime”. Esto también es una medida de cuánto espacio para el encabezado tiene antes de pierda cuadros.

Profiler Timeline

La parte superior de la ventana del perfilador muestra los datos de rendimiento en el tiempo. Cuando usted corre un juego, la información es guardada en cada cuadro, y la historia de los últimos cientos de cuadros se muestra. Haciendo click en un cuadro en particular va a mostrar sus detalles en la parte inferior de la ventana. Los detalles diferentes son mostrados dependiendo de cuál área de la linea del tiempo está actualmente seleccionada.

La escala vertical de la linea del tiempo es administrada automáticamente y va intentar llenar el espacio vertical de la ventana. Tenga en cuenta que para obtener más detalles de digamos del área del uso del CPU usted puede quitar las áreas de Memory y Rendering. Además, el divisor entre la línea de tiempo y el área de estadísticas se puede seleccionar y arrastrar hacia abajo para aumentar el área de la pantalla utilizada para la gráfica de la linea del tiempo.

La linea de tiempo consiste en varias áreas: El uso del CPU, Rendering y Memory. Estas áreas pueden ser quitadas al hacer click en el botón de cerrar en el panel, y re-agregadas nuevamente usando el despegable Add Area en la barra de los controles del perfilador.

Tenga en cuenta que los cuadrados coloreados en el área de la etiqueta pueden controlar si se muestra la línea de tiempo asociada o no. Para quitar una muestra de la pantalla haga click en la tecla de color. La tecla se atenuará, y los datos serán removidos de la gráfica. Esto puede ser útil para identificar la causa de los picos de la gráfica de la CPU, por ejemplo.

WebGL

Usted puede utilizar el Unity Profiler en WebGL, como cualquier otra plataforma. Una importante distinción es que usted no puede adjuntar a los reproductores corriendo en WebGL, aunque, Web GL utilice WebSockets para comunicación, lo cual no va a permitir conexiones entrantes por el lado del navegador. Más bien, usted necesita utilizar la casilla de verificación del “Autoconnect profiler” en los build settings. Tenga en cuenta que las draw calls no pueden ser profiled (perfiladas) actualmente para WebGL.

Remote Profiling

To profile your game running on another device or a Unity player running on another computer, you can connect the Unity Editor to that other device or computer. The dropdown Active Profiler shows all Unity players running on the local network. These players are identified by player type and the host name running the player “iPhonePlayer (Toms iPhone)”.

To be able to connect to a Unity player, you must launch that Unity player as a Development build (menu: File > Build Settings…).

Check the Development Build option in the dialog box. From here you can also check Autoconnect Profiler to make the Editor and Player Autoconnect at startup.

iOS

Enable remote profiling on iOS devices by following these steps:

  1. Connect your iOS device to your WiFi network. (The Profiler uses a local WiFi network to send profiling data from your device to the Unity Editor.)
  2. In the Unity Editor’s Build Settings dialog box (menu: File > Build Settings…), check the Autoconnect Profiler checkbox.
  3. Attach your device to your Mac via cable. In the Unity Editor’s Build Settings dialog box (menu: File > Build Settings…), check the Autoconnect Profiler checkbox and select Build & Run.
  4. When the app launches on the device, open the Profiler window in the Unity Editor (Window > Analysis > Profiler).

Si usted está usando un firewall, usted necesita asegurarse que los puertos 54998 a 55511 estén abiertos en las reglas de salida del firewall - estos son los puertos utilizados por Unity para un profiling remoto.

Note: Sometimes the Unity Editor might not autoconnect to the device. In such cases you can initiate the Profiler connection from Profiler window Active Profiler drop down menu by select appropriate device.

Android

There are two methods to enable remote profiling on Android devices: WiFi or ADB.

Para un profiling con WiFi, siga los siguientes pasos:

  1. Asegúrese de desactivar Mobile Data(datos móviles) en su dispositivo Android.
  2. Connect your Android device to your WiFi network.(The Profiler uses a local WiFi network to send profiling data from your device to the Unity Editor.)
  3. Attach your device to your Mac or PC via cable. Check the Development Build and Autoconnect Profiler checkboxes in Unity’s Build Settings dialog box, and click on Build & Run in the Unity Editor.
  4. When the app launches on the device, open the Profiler window in the Unity Editor (Menu: Window > Analysis > Profiler).
  5. If the Unity Editor fails to autoconnect to the device, select the appropriate device from the Profiler window Active Profiler drop down menu.

Tenga en cuenta: El dispositivo Android y computador host (corriendo el Editor de Unity) deben ambos estar en la misma subnet para que la detección del dispositivo funcione.

Para el profiling ADB, siga estos pasos:

  • Attach your device to your Mac or PC via cable and make sure ADB recognizes the device (i.e. it shows in adb devices list).
  • In the Unity Editor’s Build Settings dialog box (menu: File > Build Settings), check the Development Build checkbox and select Build & Run.
  • When the app launches on the device, open the Profiler window in the Unity Editor (Menu: Window > Analysis > Profiler).
  • Select the AndroidProfiler(ADB@127.0.0.1:34999) from the Profiler Window Active Profiler drop down menu. Note: The Unity Editor automatically creates an adb tunnel for your application when you click on Build & Run. If you want to profile another application or you restart the adb server you have to setup this tunnel manually. To do this, open a Terminal window / CMD prompt and enter:
adb forward tcp:34999 localabstract:Unity-{insert bundle identifier here}

Tenga en cuenta: La entrada en el menú despegable es solamente visible cuando el objeto destino seleccionado sea Android.

Si usted está usando un firewall, usted necesita asegurarse que los puertos 54998 a 55511 estén abiertos en las reglas de salida del firewall - estos son los puertos utilizados por Unity para un profiling remoto.


• 2017–05–16 Page amended with no editorial review

Profiler overview
Área de Uso del CPU(CPU Usage Area)