Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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:
    205
    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:
    33
    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:
    205
    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:
    11
    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:
    205
  6. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    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:
    137
    RobertOne likes this.
  8. marwanzaky

    marwanzaky

    Joined:
    Mar 20, 2019
    Posts:
    11
    endangeredAnimal and RobertOne like this.
  9. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    399
    Interesting! Is 2021.2 still slower? Did anyone test it on M1 Max? I’m considering the new Mac Studio but if i need to use 2021.2 to use the Silicon version it might be same or worse even on a new machine? :/
     
  10. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    205
    2021.2 has zero improvements over that. I gave up tbh and stick to unity 2019 as long as i can. 2020 is still fine to use tho. But everything after that: unusable in my opinion

    Also for compile times m1 vs m1 ultra wont be a noticeable difference since script compilation uses just 1 single core