Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        public static string ToCSV(CompileTimeKeyframe keyframe)
        {
            if (keyframe == null)
            {
                return("");
            }

            return(string.Format("{0},{1},{2}", keyframe._computedDate, keyframe.elapsedCompileTimeInMS, keyframe.hadErrors));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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>();
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 private void Load()
 {
     this._startTime          = EditorPrefs.GetInt(this._editorPrefKey + "._startTime");
     this._compileTimeHistory = CompileTimeKeyframe.DeserializeList(EditorPrefs.GetString(this._editorPrefKey + "._compileTimeHistory"));
 }
Ejemplo n.º 11
0
 public void AddCompileTimeKeyframe(CompileTimeKeyframe keyframe)
 {
     this._compileTimeHistory.Add(keyframe);
     this.Save();
 }
Ejemplo n.º 12
0
 private void HandleCompileTimeKeyframeAdded(CompileTimeKeyframe keyframe)
 {
     this.Repaint();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
        }