Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Bug Compile times twice as long then previous versions

Discussion in '2021.2 Beta' started by RobertOne, Jun 10, 2021.

  1. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    121
    how to measure compile times:
    add this script to an empty project:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4. class CompileTime : EditorWindow {
    5.  
    6.     bool isTrackingTime;
    7.     double startTime, finishTime, compileTime;
    8.     [MenuItem("Window/Compile Times")]
    9.     public static void Init() {
    10.         EditorWindow.GetWindow(typeof(CompileTime));
    11.     }
    12.     void Update() {
    13.         if (EditorApplication.isCompiling && !isTrackingTime) {
    14.             startTime = EditorApplication.timeSinceStartup;
    15.             isTrackingTime = true;
    16.         }
    17.         else if (!EditorApplication.isCompiling && isTrackingTime) {
    18.             finishTime = EditorApplication.timeSinceStartup;
    19.             isTrackingTime = false;
    20.             compileTime = finishTime - startTime;
    21.             Debug.Log("Script compilation time:" + compileTime.ToString("0.000") + "s");
    22.         }
    23.     }
    24. }
    https://pastebin.com/GeBm4vMT

    1. now you got a new editor window under Window: Compile Times. You need to open that Compile time window and leave it open, otherwise it wont work. You need to open up the compile times window(Window: Compile Times) and just dock it somewhere visible

    2. Create a empty new c# script and hit enter. unity starts the compiling process. And now you should have in the console something like this: "Script compilation time:1.532s" - this is the thing I wanna see :) Do it a few times. at the first try the time can be 4-5 seconds. after 2 or 3 attempts you should have a constant value
    my times:
    windows 10, 10th gen i9:

    unity 2019LTS: Script compilation time:1.772s
    unity 2020LTS: Script compilation time:1.867s
    unity 2021.2: Script compilation time:3.235s
     
    Last edited: Jun 10, 2021
  2. sk0g

    sk0g

    Joined:
    Mar 5, 2021
    Posts:
    32
    Following.

    Out of curiosity, was this the same project across all editors, or a fresh project in each?
     
  3. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    121
    yes. always a fresh and new clean project using the... default render pipeline ( no HDRP, no URP). and then there is just this one script in the project
     
    Last edited: Jun 10, 2021
  4. marwanzaky

    marwanzaky

    Joined:
    Mar 20, 2019
    Posts:
    5
    Did you take this test on M1? "unity 2021.2: Script compilation time:3.235s"
     
    RobertOne likes this.
  5. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    121
  6. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    47
    i can also reproduce this - the editor freezes for longer after adding or editing scripts under 2021.2 than earlier versions of Unity.

    here are my results running OP’s test:
    2020.3: 2.2s
    2021.1: 3.5s
    2021.2: 4.4s

    this is on a 2018 MacBook Pro 15” (Intel 8850H)
     
    RobertOne likes this.
  7. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    47
    RobertOne likes this.
  8. marwanzaky

    marwanzaky

    Joined:
    Mar 20, 2019
    Posts:
    5
    endangeredAnimal and RobertOne like this.
unityunity