Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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