private void RenderMenuBar() { GUILayout.BeginHorizontal(); GUILayout.Label(m_SourceTrimmed); // Add the option to reload the current data GUI.enabled = (m_Data == null && !string.IsNullOrEmpty(m_Source)); if (GUILayout.Button("Reload")) { Profiler.AddFramesFromFile(m_Source); m_SourceTrimmed = string.Format("Loaded from {0}", System.IO.Path.GetFileName(m_Source)); AnalyzeProfile(); } GUI.enabled = true; if (GUILayout.Button("Load New")) { string source = LoadProfile(); if (!string.IsNullOrEmpty(source)) { m_Source = source; m_SourceTrimmed = string.Format("Loaded from {0}", System.IO.Path.GetFileName(m_Source)); } } if (GUILayout.Button("Analyze")) { AnalyzeProfile(); m_Source = ""; m_SourceTrimmed = string.Format("Taken from Editor at {0}", DateTime.Now.ToString("t")); } GUILayout.EndHorizontal(); }
// Use this for initialization void Start() { if (loadProfilerData) { Profiler.AddFramesFromFile(Application.dataPath + "/profilerLog.txt"); } }
private void OnGUIViewer() { if (GUILayout.Button("Reload", GUILayout.Width(120))) { this.fileList = null; } if (fileList == null) { LoadProfiledList(); return; } scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); foreach (var file in fileList) { if (GUILayout.Button(file, GUILayout.Width(320))) { #if UNITY_2018_1_OR_NEWER string path = System.IO.Path.Combine(saveDir, file); #else string path = System.IO.Path.Combine(saveDir, file.Substring(0, file.Length - 5)); #endif Profiler.AddFramesFromFile(path); } } EditorGUILayout.EndScrollView(); }
static int AddFramesFromFile(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); Profiler.AddFramesFromFile(arg0); return(0); }
private string LoadProfile() { string filename = EditorUtility.OpenFilePanelWithFilters( "Open profile data file", "", new string[] { "Profile files", "data", "All files", "*" }); if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return(null); } Profiler.AddFramesFromFile(filename); AnalyzeProfile(); return(filename); }
private void OnClickSendToProfiler() { if (slicer == null) { return; } int startFrame = Mathf.RoundToInt(this.frameSlider.minValue); int endFrame = Mathf.RoundToInt(this.frameSlider.maxValue); int frameNum = endFrame - startFrame + 1; bool flag = slicer.CreateTmpFile(startFrame, frameNum, TmpFileName); if (flag) { Profiler.AddFramesFromFile(TmpFileName); } }
void OnGUI() { GUILayout.BeginHorizontal(); GUILayout.Label(LogProfilerDir); if (GUILayout.Button("Change dir")) { LogProfilerDir = EditorUtility.OpenFolderPanel("Load Profile Data", "", ""); CurLogProfilerDir = null; } GUILayout.EndHorizontal(); if (string.IsNullOrEmpty(LogProfilerDir) || !Directory.Exists(LogProfilerDir)) { return; } var files = GetFiles(); if (files == null) { return; } for (var i = 0; i < files.Length; ++i) { var toggle = EditorGUILayout.Toggle(i.ToString(), CurSelectFileIndex == i); if (toggle) { CurSelectFileIndex = i; } } if (LastSelectFileIndex != CurSelectFileIndex) { LastSelectFileIndex = CurSelectFileIndex; var path = Path.Combine(CurLogProfilerDir, files[LastSelectFileIndex]); Debug.Log(path); Profiler.AddFramesFromFile(path); } }
void OnGUI() { EditorGUILayout.LabelField("Profiler Bin Log File"); EditorGUILayout.BeginHorizontal(); string oldFile = this.filePath; this.filePath = EditorGUILayout.TextField(this.filePath); if (GUILayout.Button("File", GUILayout.Width(40.0f))) { this.filePath = EditorUtility.OpenFilePanel("", "Select BinaryLogFile", "data"); } if (oldFile != this.filePath) { this.currentFrame = 0; this.currentFilePos = 0; } EditorGUILayout.EndHorizontal(); readFrameNum = EditorGUILayout.IntField("ReadFrameNum", readFrameNum); if (GUILayout.Button("Send to Profiler")) { try { bool flag = CreateTmpFile(readFrameNum); if (flag) { Profiler.AddFramesFromFile(TmpFileName); } } catch (System.Exception ed) { } } GUILayout.Label("Frame " + currentFrame); if (GUILayout.Button("Reset Frame")) { this.currentFrame = 0; this.currentFilePos = 0; } }
[MenuItem("Window/readfile")] public static void Read() { var dataFileProfilerName = "prof/prof_0001"; var dataFileName = dataFileProfilerName + ".data"; var header = new byte[16]; using (var fs = File.OpenRead(dataFileName)) { while (true) { // ヘッダサイズ16byte fs.Read(header, 0, header.Length); int size = GetIntValue(header, 8); // オフセットの前のとこは最初は固定値なんだけど、なんか情報を含んでそう。同じファイルに複数フレーム含んだ場合かな。 Debug.LogError("データのsize:" + size + " こんだけのサイズのデータがあるはず。"); // 1フレームのデータがこれ。 var buffer = new byte[size]; fs.Read(buffer, 0, size); // ということで、あとは中身をアレする。 using (var sw = File.OpenWrite("exp")) { sw.Write(buffer, 0, buffer.Length); } if (fs.Position == fs.Length) // read to end. { break; } } } Profiler.AddFramesFromFile(dataFileProfilerName); }
void OnGUI() { if (GUILayout.Button("Find Files")) { ReadProfilerDataFiles(); } if (cachedFilePaths == null) { return; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Files"); EditorGUILayout.BeginHorizontal(); // create some styles to organize the buttons, and show // the most recently-selected button with red text GUIStyle defaultStyle = new GUIStyle(GUI.skin.button); defaultStyle.fixedWidth = 100f; GUIStyle highlightedStyle = new GUIStyle(defaultStyle); highlightedStyle.normal.textColor = Color.red; for (int i = 0; i < cachedFilePaths.Count; ++i) { // list 5 items per row if (i % 5 == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); } GUIStyle thisStyle = null; if (chosenIndex == i) { thisStyle = highlightedStyle; } else { thisStyle = defaultStyle; } if (GUILayout.Button(buttonNames[i], thisStyle)) { Profiler.AddFramesFromFile(cachedFilePaths[i]); chosenIndex = i; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Open File Location")) { string path = EditorUtility.OpenFilePanel("Choose file to load", Application.persistentDataPath, "*"); if (path != "") { Profiler.AddFramesFromFile(path); } } }
private void Some() { Profiler.AddFramesFromFile(""); }
public static void AddFramesFromFile(string file) { Profiler.AddFramesFromFile(file); }
void Start() { Profiler.AddFramesFromFile("perfomance.log"); }