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