Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save unitycoder/2338ea62b5ae45c575c22e28258a3835 to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/2338ea62b5ae45c575c22e28258a3835 to your computer and use it in GitHub Desktop.
How to profile build time for a Unity project
1) Enable Profiler in OnPreprocessBuild like following:
public void OnPreprocessBuild(BuildReport report)
{
Profiler.enabled = true;
Profiler.enableBinaryLog = true;
Profiler.logFile = "profilerlog.raw";
Debug.Log("Enabling Profiler");
}
2) Disable Profiler in OnPostProcessBuild
3) Now put Profiler.Begin/EndSample in the desired code.
4) Build project. This will save a profile data into profilerlog.raw file in your project folder.
5) Now open Profiler window and load the the .raw file by clicking on the load binary button in the toolbar.
6) Make sure to disable `Collapse Editor Only samples` to view editor samples in detail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment