Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created June 10, 2021 07:23
Show Gist options
  • Save unitycoder/498231e7f7f08a6b755e0b367f703c46 to your computer and use it in GitHub Desktop.
Save unitycoder/498231e7f7f08a6b755e0b367f703c46 to your computer and use it in GitHub Desktop.
measure compile time unity editor
// https://forum.unity.com/threads/compile-times-twice-as-long-then-previous-versions.1123711/
using UnityEngine;
using UnityEditor;
using System.Collections;
class CompileTime : EditorWindow {
 
    bool isTrackingTime;
    double startTime, finishTime, compileTime;
    [MenuItem("Window/Compile Times")]
    public static void Init() {
        EditorWindow.GetWindow(typeof(CompileTime));
    }
    void Update() {
        if (EditorApplication.isCompiling && !isTrackingTime) {
            startTime = EditorApplication.timeSinceStartup;
            isTrackingTime = true;
        }
        else if (!EditorApplication.isCompiling && isTrackingTime) {
            finishTime = EditorApplication.timeSinceStartup;
            isTrackingTime = false;
            compileTime = finishTime - startTime;
            Debug.Log("Script compilation time:" + compileTime.ToString("0.000") + "s");
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment