/UECompileTimesVisualizer

Debug compile times in Unreal Engine & MSVC projects

Primary LanguagePythonMIT LicenseMIT

Unreal Engine & MSVC Compile Times Visualizer




This program is outdated

In recent Unreal Engine versions, you should be able to just set bPrintToolChainTimingInfo to true in your BuildConfiguration.xml (see below).

You can then compile Engine\Source\Programs\Windows\CompileTimeAnalyzer and use it to load the .timing files located in your Intermediate folder.

The Compile Score VS extension also works great with Unreal if you want to see how much you're spending including files: https://marketplace.visualstudio.com/items?itemName=RamonViladomat.CompileScore2022




Previous Readme

Note: as this is using a disk visualizer as output, the following convention is used:

1MB = 1s | 1B = 1 micro second

What is this

It's a frontend for the msvc timing output log. With it you'll be able to see which function takes time to compile, which headers are included by your files and how expensive they are...

Basically if you want to speed up your compilation in UE or in a project using MSVC this should help a lot :)

Links

MSVC dev team blog post about compiler speed

Aras P. blog post about compile times

How to add PCHs in UE

UE Forum thread

Usage

Unreal Engine

  • Copy BuildConfiguration.xml to %appdata%\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml, or if your already have one:
    • add <bPrintToolChainTimingInfo>true</bPrintToolChainTimingInfo> to the BuildConfiguration category
    • add <CompilerVersion>Latest</CompilerVersion> to the WindowsPlatform category (or a toolchain >= to 14.14.26316)
    • disabling Unity build is recommended: add <bUseUnityBuild>false</bUseUnityBuild> to the BuildConfiguration category
  • Build your solution (the output should be spammed with log)
  • VS might crash because of that. If it happens, you can edit UBT to fix it (works even without a source build!):
    • Open Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj
    • Open System\ParallelExecutor.cs
    • Find the following line: Log.TraceInformation("{0}", CompletedAction.LogLines[LineIdx]); (should be around line 198) and replace it by
var Line = CompletedAction.LogLines[LineIdx];
if (Line.Contains(" error") || Line.Contains(" warning") || Line.Contains(" note"))
{
    Log.TraceInformation("{0}", Line);
}
else
{
    Log.TraceLog("{0}", Line);
}
    • Rebuild the solution (will only rebuild UBT in a launcher build)
    • Note: some errors/warnings might not be shown with this hack. You should change it back once you're done testing
  • Once the build is finished, copy Engine\Programs\UnrealBuildTool\Log.txt next to main.py
  • Run main.py with python
  • It'll create 3 csv: result_includes.csv, result_functions.csv, result_classes.csv. You can open those in wiztree
  • 1MB = 1s

MSVC

  • Add the following arguments to the C/C++ Command Line option in your project settings: /Bt+ /d2cgsummary /d1reportTime
  • Add the following argument to the Linker Command Line option in your project settings: /time+
  • Rebuild your solution. The output should be spammed with log
  • Find your build log file. For me it was under MyProject/MyProject/Debug/MyProject.log
  • Copy it next to the main.py and rename it to Log.txt
  • Run main.py with python
  • It'll create 3 csv: result_includes.csv, result_functions.csv, result_classes.csv. You can open those in wiztree
  • 1MB = 1s

Script args

First arg: log file, defaults to Log.txt

Second arg: destination, defaults to result

Outputs

Most included files

The script will print the headers and the number of times they were included. This can be used to decide which headers should go in a PCH.

Includes

See which headers are included by your files, and how long they took to include.

Classes

See which classes are compiled in your files, and how long it took.

Functions

See which functions are compiled in your files, and how long it took.