Skip to content

Instantly share code, notes, and snippets.

@phi-lira
Created July 15, 2020 12:08
Show Gist options
  • Save phi-lira/4fc6e6c4fb996d25edbd60437f51c9e2 to your computer and use it in GitHub Desktop.
Save phi-lira/4fc6e6c4fb996d25edbd60437f51c9e2 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