Unity Profiler

Unity is a powerful tool with a very powerful profiler tool that is a pleasure to work with and explore, not just for profiling, but it also provides an insight into the inner workings of Unity. Open up the Unity editor to one of the sample projects we have worked with. For this example, we will use HoloCore from Chapter 10, Mixing in Mixed Reality, but feel free to use another app if you prefer. With the editor open, perform the following steps:

  1. From the menu, select Window | Profiler. The window will open undocked. Drag the window over by the tab and drop it beside the Game window tab to dock it on the right. Normally, we would dock the Profiler beside the Inspector so that you can watch the profiling while running a game in the editor. Since we can't run ARCore apps in the editor, for now, we will give the Profiler more room by docking it next to the Game window.
  1. Open the Build Settings dialog and check whether the Development Build and Autoconnect Profiler settings are enabled, as shown in the following screenshot:
Setting Development Build settings
  1. Connect your device with a USB, build, and run. Leave the app running on your device.
  2. Return to the editor and open the Active Player dropdown and select AndroidPlayer([email protected]:someport), as shown here:
Unity Profiler capturing session from Android device
  1. Click on one of the spikes, as shown in the preceding screenshot. With the CPU panel selected, direct your attention to the bottom Details panel.
  2. Use the dropdown to select Timeline, as follows:
Inspecting the details of a profiling session
  1. There is plethora of useful information here, and it can certainly be overwhelming at first. Fortunately, the Unity interface is self-documenting, and you can quickly get a sense of what is good or bad. We will go over what areas to watch for in more detail later, but for now, pay attention to the Rendering time and Total Allocated Memory. For rendering times, you will usually see a number in ms or milliseconds in time and FPS or frames per second. A good rule is to ensure that your frame rate stays above 30 FPS. A memory can equally be critical when building for mobile apps.
  2. When you are profiling, put the app under stress by changing between reality modes, if you are using HoloCore, for instance. Then, continue drilling into the various detail panels and watch how values change at various points of the app session.

The Unity tools provide the most powerful and intuitive interface for profiling your app. While we barely scraped the power of all the tools we looked at, you will note that they all bear a strong resemblance. Of course, this is not by accident and after you learn the ins and outs of performance profiling an app on one platform, a number of those skills will carry over. In the next section, we will look at a list of tips for better app performance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.214.177