Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Novack/2e0e2e4c72ce04d8f4366f9b0796f46f to your computer and use it in GitHub Desktop.

Select an option

Save Novack/2e0e2e4c72ce04d8f4366f9b0796f46f to your computer and use it in GitHub Desktop.
Find out what assemblies are being built and how long each takes.
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEditor.Compilation;
[InitializeOnLoad]
public class AsmdefDebug
{
static Dictionary<string, Stopwatch> s_Assemblies = new Dictionary<string, Stopwatch>();
static AsmdefDebug()
{
UnityEngine.Debug.Log("Setting up");
CompilationPipeline.assemblyCompilationStarted += CompilationPipelineOnAssemblyCompilationStarted;
CompilationPipeline.assemblyCompilationFinished += CompilationPipelineOnAssemblyCompilationFinished;
}
static void CompilationPipelineOnAssemblyCompilationStarted(string obj)
{
var sw = new Stopwatch();
s_Assemblies[obj] = sw;
sw.Start();
}
static void CompilationPipelineOnAssemblyCompilationFinished(string arg1, CompilerMessage[] arg2)
{
var sw = s_Assemblies[arg1];
sw.Stop();
UnityEngine.Debug.Log(arg1 + "\nTime:" + sw.Elapsed.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment