Last updated February 2020, 10 min read. 

Optimize your game with the Profile Analyzer

What you'll get from this page: You'll learn how to use Unity’s Profile Analyzer to see the impact of an asset or code change, optimization work, a settings modification, or an upgrade in the Unity version. This article is based on Lyndon Homewood’s session at Unite Copenhagen 2019.

Overview of the Profile Analyzer

Do you want to know where to focus your performance efforts? Do you need to compare performance before and after a change? Are you aware of the impact that a Unity version update has on your game? The Performance Analyzer will help get this overview. 

The tool helps you identify where to focus your efforts, and it provides you with a way to compare two Unity performance captures and see the impact of your change. The tool provides visual representations to help you understand how your changes affect the performance. 

The Profile Analyzer aggregates and visualizes frame and marker data from a set of Unity Profiler frames to help you reason about their behavior over many frames, complementing the single frame analysis already available in the Unity Profiler.

The Profile Analyzer conducts CPU performance analysis on multiple frames. The tool comes with statistics and visualizations to help you digest that information quickly. It also supports Comprehensive Filtering, so you can drill down into the sections that you’re interested in. You can use it to compare two data sets, or you can export the data for analysis with other tools. 

You can use the Profile Analyzer in 2018.4 LTS+ as a package, but you can also download it and then drop it into your project. It works with any Unity version from 5.6 onwards. To launch it, go to Window > Analysis > Profile Analyzer. With older Unity versions, you can launch it directly from the Window menu.

Profiling tips

Here are some profiling tips to help you get started with the Profile Analyzer: 

  1. Get a representative and repeatable capture.
  2. Close all other applications. You can use Profile.logFile in your C# scripts to write out Profile data directly from the running game, which means you don’t need the Editor to be open. It writes out a .raw file that you can load into the Unity Profiler afterwards. 
  3. Disable the CPU performance scaling so you don’t get a change in your clock frequency, such as the Intel SpeedStep or Turbo Boost settings.

Reviewing performance for a specific function

If you want to see how calling a function impacts performance, use the Unity Profiler to capture your data. Then you can use the Pull Data button to load it into the Profile Analyzer. Or, you can load a previously saved capture. 

As soon as you do that, the analysis starts immediately and the data populates the frame time graph. Notice the white and cyans bars in the graph. The white bars represent the frame durations and the cyan bars represent the currently selected markers, so you can see how much they contribute to the frame time. 

You can search for your markers using Filters. The Marker Details automatically update to reflect the subset that you’ve selected, and in the Count column you’ll see how many occurrences it has. The frame time graph highlights the marker. When you select a marker, the Marker Summary also updates. 

 

Finding representative frames

When analyzing performance, you want to make sure that the data you’re looking at is representative. If your data is noisy, it’s easy to ensure that you select an average frame by using the Frame Summary at the top right – just click on the Frame shown as the Median and the Profiler will display the relevant analysis. Or, in the frame time graph, you can right-click and select Select Median Frame

You can also limit your analysis to a selection of frames. All of the statistics you see will be updated to reflect the specific selection. 

Rather than rely on a single data point from a single frame, you can analyze multiple data points by selecting a group of representative frames. If you right-click on the frame time graph and Order by Frame Duration, you can then select a set of frames around the median frame for a representative sample that smooths out some of the noise in your data.

The effect of changing a project setting

The Profile Analyzer can help determine the performance difference when applying a project-wide setting such as enabling Graphics Jobs. To use this feature, take a baseline capture and then take another capture after you make changes. Run your game, sample it with the Unity Profiler, bring that capture over into the Profile Analyzer, and then bring the second one in.

You can see the results of the two captures side by side in the Frame Summary section.

Are you GPU-bound?

To make sure your performance doesn’t have any bottlenecks, check the Gfx.WaitForPresent marker. Find it by typing Gfx.WaitForPresent into the filter area. If the median value of that marker is nonzero, then the CPU is waiting on the GPU to finish its activity before it can continue. 

You can look at that marker in the Frame Time Graph to see how much it contributes to frame time. If the CPU is waiting for the GPU, and you’re most likely GPU-bound. Have a look at the GPU profiling tools to make some optimizations. 

Profile Analyzer interface basics
Data set management

Data set management

You can manage your data from the main top section of the Profile Analyzer window. From here you can open the Unity Profiler, and “Pull Data” from the Unity Profiler or load a previously saved file (any Unity version). 

Once you’ve loaded your data, you’ll see it in the frame time graph. This is an interactive region where you can select a range of samples; all of the summary information in the Marker Table will automatically update to reflect your selection. You can access more advanced options by right-clicking on your selection. 

You can click the “Save” button to save your analysis data as a .pdata file. Note that there are two save files — a Profile Analyzer save file (.pdata) and a Profiler save file (.data or .raw). We recommend saving both files in the same directory. 

 

Frame Summary

The Frame Summary displays highlights on the frame time, including the minimum, maximum and median, with buttons that let you jump to specific frames in the Unity Profiler. This area also shows you the frame time distribution histogram and box and whisker plot. 

profile analyzer singel view populated frame graph marker table

Marker Table

Marker Details

In this section, you’ll find the marker table of the marker data from the Unity Profiler, including all stack depths. The Unity Profiler data for all the markers are aggregated to provide median and other frame times, which are also displayed in this table. 

 

Marker Summary

The Marker Summary area at the right contains aggregated information about the selected markers and their contribution to frame time. This information is also presented visually in a histogram and a box and whisker plot.

At the bottom of the summary, you’ll find the minimum and maximum times for individual marker instances within the aggregated data set.  

profile analyzer compare view frames and filters

Filters

  1. By name

To focus your review to markers with a specific name, you can type in a substring or a collection of substrings. If the name contains spaces, make sure to put quotes around the substring. 

You can exclude the markers you’re not interested in. For example, you can exclude markers based on the idle time in Jobs or the markers that are part of the Profiler itself. 

You can populate the filters by right-clicking on a marker of interest in the table. 

  1. Threads

You can choose to see data for specific worker threads. To see all of them aggregated, check “All” at the top of the thread Select pop-up window. 

  1. Depth

We recommend looking at depth 3 because most of the Unity subsystems have high-level markers at that level. That way, you see the contribution of key subsystems like rendering, animation, and physics. (Depth 3 is appropriate for recent Unity releases. For older releases, you may want to switch to another depth.)

  1. Parent

To filter by parent, right-click on the marker in the marker table and select Set as Parent Marker Filter.

  1. Analysis Type

By default, the Profile Analyzer shows you Total time for the markers, but you can change to Self time. Self time is useful if you want to drill down to details to see where your time is really spent. 

  1. Units

The default units are milliseconds, but for smaller timings, you can switch to microseconds.

Top 10 markers

The top 10 markers are the top 10 for the filters that you’ve set. The best way to use this tool is to select the Main Thread and total time including children at depth 3, so that you look at the Unity subsystems. This will show you the ratio of contribution for each of those key systems, such as rendering versus physics versus animation time. For further reporting and analysis, you can hover over the data bar to see the exact percentages and metrics. 

profile analyzer comparison data tab

Comparing data sets

At the top of the Profile Analyzer window, you can switch to the Compare tab to select two data sets for analysis. One data set is displayed in blue, and the other in orange. Or you can choose to compare two subregions of a single data set, for example, to compare your median frames against your outlier frames. 

The Marker Comparison table visually represents the data in blue and orange, so you can quickly check which of your two data sets is running slower in certain areas.

If the marker is absent in one of the scans, you’ll see a dash in that column. This can happen if the marker has been renamed, for example, if you’re using different Unity versions.
 

Exporting data

Remember that you can export the data from the Profile Analyzer for more custom processing. You can export the contents of the marker table, the frame time graph, or a comparison of frame time graphs.

If you have questions about the Profile Analyzer, the Profiler, or how to use their specific features for your project, join the discussions on the forums

We use cookies to ensure that we give you the best experience on our website. Visit our cookie policy page for more information.

Got it