Search Unity

Have you ever needed to compare the difference in performance between two versions of your project? See the impact of an asset or code change, optimization work, settings change or Unity version upgrade? Read on to find out how our Profile Analyzer (Preview) can help you!

Built out of necessity

As part of Unity’s Platform Performance Team, we get to investigate all kinds of performance problems, on any of the Unity supported platforms or in any version of Unity. To do this, we rely heavily on the native platform tools and, of course, on the Unity Profiler.

During one such investigation, we found that we were struggling to find the most representative frames of data to dig into. So we built a tool that would aggregate multiple frames of profiler data and help us locate interesting frames for any given marker. This enabled us to more reliably reason about its change in behavior.

Analyzing a single data set

Profile Analyzer’s Single View can be populated from the current set of frames in the Unity Profiler window. It analyzes the CPU data and visualizes frame, thread and marker times/counts, including their minimum, maximum, median, mean and lower/upper quartile values, and gives links back to the Profiler Window for the frames they appear in. The distribution of time for frames, threads, and markers is also available as a histogram and box and whisker plot to help visualize behavior over time.

Comparing two data sets

Building on the information shown in the Single View, you can load two data sets in the Compare View. They will appear in two distinct colors. The difference between the two data sets is visualized in an ordered table. You can also see the distribution differences in the histogram and box and whisker plots. The two data sets can be from before and after a code/data change, a project-settings change or a Unity version upgrade.

A comprehensive filtering system is available in both the Single and Compare views to limit the analysis by marker, thread, frame, and stack depth.

Filtering the data

Your working set can be reduced with the use of the filtering controls. You can limit markers by a partial name match, which thread they ran on and a specific stack level.

Along with filtering to a specific name match, you can also elect to exclude a further set of markers by name to remove any markers that aren’t statistically relevant from the filtered set or are somehow distorting the view of your filtered marker set.  Selecting a subset of frames is also available using the frame control at the top of the window.

The Compare View will automatically align the depth of the two data sets so that top-level markers are aligned correctly. However, you can override this using the Auto Right tick box and the Left and Right depth controls. This is especially useful when comparing data sets from different versions of Unity where the markers produced have changed.

Sharing the love

Profile Analyzer continues to be used internally to monitor performance and optimizations of key systems. Recently, it was used to review performance when optimizing Unity texture loading, where the creation of large textures caused render thread stalls. The searching and filtering made it simple to focus on the key metrics related to this area. To help all developers review and improve performance we released the tool as a package in sync with the 2019.1 release, give it a go and let us know how you get on, we’d love to hear your experiences on the forum.

Deixar uma resposta

Você poderá usar estes atributos e marcas HTML: <a href=""> <b> <code> <pre>

  1. This is incredibly awesome! Thanks so much for creating this.

    I’m comparing two data sets from iOS runs, one with graphics jobs disabled and another with graphics jobs enabled (actually, I’m confused about this, is graphic jobs supported in iOS using Metal? If not, why is it an option in the iOS settings?).
    Multithreaded rendering is disabled on both, but I see time spent in the Work Thread for both sets. I’m assuming this worker thread is not related to rendering in the singlethreaded rendering data set?

    I’m also seeing “541 of 538 markers” in the Filters window, is it a bug?

    1. …ok I see that when a multithreaded rendering data set is loaded “Render Thread” shows up in the Filter…. so cool!!!!

      1. This page is a useful overview of the multi threaded rendering and graphics jobs that may help you.
        It was written in relation to 2018.1.

    2. The marker count sounds like a bug. Thanks for highlighting. I am currently unable to reproduce it at the moment. Please can you raise a bug and attach both the Unity Profiler file (.data) and the Profile Analyzer file (.pdata) so we can look into it. If you reply with the case number here then I can check up on it.

      1. Thank you! It’s case 1156532. I think I found a more urgent/important issue and reported another bug, number 1156539. If you could take a look at this bug instead it would be great, as I’m relying on the numbers of the analyzer to verify if my performance changes are significant.

        1. Lyndon Homewood

          maio 22, 2019 às 12:35 pm

          I’ve replied on the issue regarding the ‘Top Marker’ display.

          The display is functioning correctly but the UI is not clear enough to inform you of the difference between the values.
          We will look into improving it in a later version, so I’ll keep the issue open until the UI is updated.

          Summary from issue:

          The Top 10 Marker bar shows the marker value on the median frame. This frame is the one with the median total frame time.
          The comparison graph shows the median of all the samples over all the frames.
          So these two may not match.

          If you switch to the single view there are two columns.
          ‘Median’ is the median value of the marker over all frames (same as the comparison view).
          ‘At Median Frame’ is the value of the marker on the ‘median frame’ with the median overall frame time. (same as seen in the top 10 view)

          If you click on the frame time graphs and choose “Select Median Frame” for both data sets, then the values will all match.

          Hopefully that clears up the confusion and reassures you that the values are reliable (And that the UI will be reviewed).

  2. Emil "AngryAnt" Johansen

    maio 14, 2019 às 12:38 pm Responder

    One of the big things we are looking forward to. Much excite! :)

    Our development builds by default output profiler data to timestamped collections. Will it be somewhat straight forward to present a list of profile dumps to generate analysis for and then cycle through and compare them? Or is that just something we’ll be writing our own little tooling for?

    1. Currently the tool requires you to open the profile with the Unity Profiler first to get it into the analyser. I.e. Either load a saved .data or .raw file into the Unity Profiler (or perform a new capture with the Profiler), then open the Profiler Analyser tool and click ‘pull’ to grab the data for analysis. Then the analysis can be saved out as a .pdata file for future review or comparison. We recommend you keep the .data file alongside the .pdata file so you can jump between the profiler and analyser if needed. Generally I’ve found the workflow quite fast and usually have the Unity Profiler and Unity Profile Analyser docked together side by side so I can jump between overview and individual frame analysis.

      It may be possible to automated that .raw to .pdata conversion as part of your workflow so you can simply have a folder of .pdata files for opening with the tool. Thanks for highlighting your specific use case.

      1. Emil "AngryAnt" Johansen

        maio 14, 2019 às 1:36 pm Responder

        Excellent! I have no doubt we’ll have that running just perfectly adjusted to our needs in no time. Thanks again :)

  3. Great !

    Will this support to connect the device or using IP

    1. This tool pulls data from the standard Unity Profiler.
      So you can use all the standard connection methods of the Unity Profiler to capture data from devices.

      You can also use the C# Profiler.logFile API in your applications to write out a performance capture, then load this into the Unity Profiler and use the Profile Analyser to review that data.

  4. Looks great!

    Does the analysis only run retrospectively, or is there a ‘live’ mode?
    Interesting possibilities, e.g. to pause execution if an unusual frame occurs.

    1. Thanks for the feedback,

      The tool was designed to be run after the capture as this allows more time for the analysis to be performed.
      The analysis time is dependent on the complexity of the project and the number of markers output in the capture.
      This time is currently likely to be longer than the frame time for a complex project.