예제 #1
0
        private void ExportCSV(IEnumerable <CompileTimeKeyframe> keyframes, string fileName)
        {
            var path = EditorUtility.SaveFilePanel("Export compile times to CSV", "", string.Format("{0}.csv", fileName), "csv");
            var csv  = CompileTimeKeyframe.ToCSV(keyframes as List <CompileTimeKeyframe>);

            System.IO.File.WriteAllText(path, csv);
        }
예제 #2
0
        public static string Serialize(CompileTimeKeyframe keyframe)
        {
            if (keyframe == null)
            {
                return("");
            }

            return(string.Format("{1}{0}{2}{0}{3}", CompileTimeKeyframe.kKeyframeDelimiter, keyframe.elapsedCompileTimeInMS, keyframe.serializedDate, keyframe.hadErrors));
        }
예제 #3
0
        public static string ToCSV(CompileTimeKeyframe keyframe)
        {
            if (keyframe == null)
            {
                return("");
            }

            return(string.Format("{0},{1},{2}", keyframe._computedDate, keyframe.elapsedCompileTimeInMS, keyframe.hadErrors));
        }
예제 #4
0
        private void Save()
        {
            while (this._compileTimeHistory.Count > CompileTimeTrackerData.kHistoryKeyframeMaxCount)
            {
                this._compileTimeHistory.RemoveAt(0);
            }

            EditorPrefs.SetInt(this._editorPrefKey + "._startTime", this._startTime);
            EditorPrefs.SetString(this._editorPrefKey + "._compileTimeHistory", CompileTimeKeyframe.SerializeList(this._compileTimeHistory));
        }
예제 #5
0
        public static List <CompileTimeKeyframe> DeserializeList(string serialized)
        {
            if (String.IsNullOrEmpty(serialized))
            {
                return(new List <CompileTimeKeyframe>());
            }

            string[] serializedKeyframes = serialized.Split(CompileTimeKeyframe.kListDelimiterArray, StringSplitOptions.None);

            return(serializedKeyframes.Select(s => CompileTimeKeyframe.Deserialize(s)).Where(k => k != null).ToList());
        }
예제 #6
0
        private static void HandleEditorFinishedCompiling()
        {
            int elapsedTime = TrackingUtil.GetMilliseconds() - CompileTimeTracker._data.StartTime;

            UnityConsoleCountsByType countsByType = UnityEditorConsoleUtil.GetCountsByType();
            bool hasErrors = (countsByType.errorCount - CompileTimeTracker.StoredErrorCount) > 0;

            CompileTimeKeyframe keyframe = new CompileTimeKeyframe(elapsedTime, hasErrors);

            CompileTimeTracker._data.AddCompileTimeKeyframe(keyframe);
            CompileTimeTracker.KeyframeAdded.Invoke(keyframe);
        }
        private void Load()
        {
            this._startTime = EditorPrefs.GetInt(this._editorPrefKey + "._startTime");
            string key = this._editorPrefKey + "._compileTimeHistory";

            if (EditorPrefs.HasKey(key))
            {
                this._compileTimeHistory = CompileTimeKeyframe.DeserializeList(EditorPrefs.GetString(key));
            }
            else
            {
                this._compileTimeHistory = new List <CompileTimeKeyframe>();
            }
        }
예제 #8
0
        private static void LogCompileTimeKeyframe(CompileTimeKeyframe keyframe)
        {
            bool dontLogToConsole = !CompileTimeTrackerWindow.LogToConsole;

            if (dontLogToConsole)
            {
                return;
            }

            string compilationFinishedLog = "Compilation Finished: " + TrackingUtil.FormatMSTime(keyframe.elapsedCompileTimeInMS);

            if (keyframe.hadErrors)
            {
                compilationFinishedLog += " (error)";
            }
            UnityEngine.Debug.Log(compilationFinishedLog);
        }
예제 #9
0
        public static CompileTimeKeyframe Deserialize(string serialized)
        {
            string[] tokens = serialized.Split(CompileTimeKeyframe.kKeyframeDelimiterArray, StringSplitOptions.None);
            if (tokens.Length != 3)
            {
                Debug.LogError("Failed to deserialize CompileTimeKeyframe because splitting by " + CompileTimeKeyframe.kKeyframeDelimiter + " did not result in 3 tokens!");
                return(null);
            }


            CompileTimeKeyframe keyframe = new CompileTimeKeyframe();

            keyframe.elapsedCompileTimeInMS = Convert.ToInt32(tokens[0]);
            keyframe.serializedDate         = tokens[1];
            keyframe.hadErrors = Convert.ToBoolean(tokens[2]);

            return(keyframe);
        }
예제 #10
0
 private void Load()
 {
     this._startTime          = EditorPrefs.GetInt(this._editorPrefKey + "._startTime");
     this._compileTimeHistory = CompileTimeKeyframe.DeserializeList(EditorPrefs.GetString(this._editorPrefKey + "._compileTimeHistory"));
 }
예제 #11
0
 public void AddCompileTimeKeyframe(CompileTimeKeyframe keyframe)
 {
     this._compileTimeHistory.Add(keyframe);
     this.Save();
 }
예제 #12
0
 private void HandleCompileTimeKeyframeAdded(CompileTimeKeyframe keyframe)
 {
     this.Repaint();
 }
예제 #13
0
 public static string SerializeList(List <CompileTimeKeyframe> keyframes)
 {
     string[] serializedKeyframes = keyframes.Where(k => k != null).Select(k => CompileTimeKeyframe.Serialize(k)).ToArray();
     return(string.Join(CompileTimeKeyframe.kListDelimiter, serializedKeyframes));
 }
예제 #14
0
        public static string ToCSV(List <CompileTimeKeyframe> keyframes)
        {
            string[] serializedKeyframes = keyframes.Where(k => k != null).Select(k => CompileTimeKeyframe.ToCSV(k)).ToArray();
            string   fields = "date,compile_time,had_errors\n";

            return(fields + string.Join("\n", serializedKeyframes));
        }