Profiling Games built with Unity* (NEW)
Use this recipe to profile a game built with the Unity game engine. See how you can run
Intel® VTune™
within the Unity environment to profile your game.
Profiler
Often, the most important factor that affects the performance of a game is the frame rate. This is the speed with which the GPU renders game graphics. However, the CPU can also impact game performance in several ways:
- Slow transfer of data to the GPU
- Slow or unnecessary operations
- Poor parallelism
Intel® VTune™
Instrumentation and Tracing Technology (ITT) API built into the Unity editor. This recipe demonstrates how you can run
Profiler
VTune Profiler
to highlight Unity tasks in the editor.
Ingredients
Here are the hardware and software requirements for this performance recipe.
- Application:Unity 2022.1.16. The sample game in this version of Unity uses the free asset 3D Game Kit.
- Tools:Intel® VTune™version 2022 - Hotspots Analysis (using User-Mode Sampling)Profiler
- Starting with the 2020 release, Intel® VTune™ Amplifier has been renamed toIntel® VTune™.Profiler
- Most recipes in theIntel® VTune™Performance Analysis Cookbook are flexible. You can apply them to different versions ofProfilerIntel® VTune™. In some cases, minor adjustments may be required.Profiler
- Get the latest version ofIntel® VTune™:Profiler
- From theIntel® VTune™product page.Profiler
- Download the latest standalone package from the Intel® oneAPI standalone components page.
- CPU/GPU: Intel® Core™ i7-8665U CPU @ 1.90GHz with integrated GPU
- Operating system: Windows* 10 Enterprise
Build the Game in the Unity Editor
- Open the game in the Unity editor.
- Build the game. Make sure to select theCopy PDB FilesandDevelopment Buildoptions.
Configure
Intel® VTune™
Profiler and Run Hotspots Analysis
Intel® VTune™
and Run Hotspots Analysis Profiler
- OpenIntel® VTune™and clickProfilerNew Projecton the Welcome screen.
- Specify a project name and a location for your project.
- ClickCreate Project.
- In theConfigure Analysiswindow, set these options:
- In theWHEREpane, selectLocal Host.
- In theApplicationfield of theWHATpane, enter the path to the game executable.
- In theApplication parametersfield, enter-profiler-enable-vtune-markers.
- (Optional) If you want to skip profiling the start/loading phase of the game,
- In theWHATpane, open theAdvancedsection.
- SetAutomatically resume collection afterto the number of seconds thatIntel® VTune™should wait for profiling to begin.Profiler
- In theHOWpane, select theHotspots analysis typeand enable user-mode sampling.
- ClickStartto run the analysis.

If you set the
) is available.
Automatically resume collection after
option in step 5, only the
Start Paused
button (
Review Results
After the data collection runs for about 30 seconds, click
Stop
to exit the game and finalize the VTune results. This process may take a few minutes as
Intel® VTune™
finds and resolves debug symbols.
Profiler
Once results have been finalized, the
Summary
tab displays information about:
- Elapsed time
- Top hotspots
- Top Unity tasks
- Additional insights and guidance

The
Frame Rate Histogram
shows the frequency at which frames executed during the collection.

In this example, most frames executed between 13-14 frames per second (FPS). This is much slower than the recommended minimum of 30 FPS.
Switch to the
Bottom-up
window to see a list of functions. The default sorting is by descending order of CPU time.
Change the grouping from
Function / Call Stack
to
Task Domain / Task Type / Function / Call Stack
to focus on Unity tasks which were identified by the
Intel® VTune™
Instrumentation and Tracing Technology API (ITT API).
Profiler

The collection was started in a paused state, and this is indicated in the timeline view as
Intel® VTune™
was still actively running.
Profiler
Select the time period when collection starts at 60 seconds and zoom in.

In this example, the frame rate is low and there is considerable spin time. In general, a game should not consume a high percentage of the CPU capacity of the system. If the worker threads have low parallelism, they may be adding too much overhead.
In one of the
RunThreadWrapper
threads, all of the CPU time is spin or overhead. Reducing the number of threads can improve performance here.

For additional insights into hotspots, open the
Flame Graph
view to see a graphical representation of call stacks from the top down.
