示例#1
0
 void Update()
 {
     try
     {
         if (logReader != null)
         {
             var data = logReader.ReadFrameData();
             if (data == null)
             {
                 return;
             }
             this.CollectData(data);
             System.GC.Collect();
             if (data == null)
             {
                 logReader = null;
             }
             this.Repaint();
         }
     }
     catch (System.Exception e)
     {
         logReader = null;
         Debug.LogError(e);
     }
 }
        private void SetAnalyzerInfo(List <IAnalyzeFileWriter> analyzeExecutes, ILogReaderPerFrameData logReader)
        {
            ProfilerLogFormat format = ProfilerLogFormat.TypeData;

            if (logReader.GetType() == typeof(UTJ.ProfilerReader.RawData.ProfilerRawLogReader))
            {
                format = ProfilerLogFormat.TypeRaw;
            }
            foreach (var analyzer in analyzeExecutes)
            {
                analyzer.SetInfo(format, Application.unityVersion, logReader.GetLogFileVersion(), logReader.GetLogFilePlatform());
            }
        }
        void Update()
        {
            try
            {
                if (logReader != null)
                {
                    var frameData = logReader.ReadFrameData();
                    if (isFirstFrame)
                    {
                        SetAnalyzerInfo(analyzeExecutes, logReader);
                        isFirstFrame = false;
                    }
                    if (frameData == null)
                    {
                        // 終わったタイミングでcsv
                        string dialogStr   = "Write to csv files\n";
                        string outputDir   = System.IO.Path.GetDirectoryName(this.filePath);
                        string logfilename = System.IO.Path.GetFileName(this.filePath);

                        foreach (var analyzer in this.analyzeExecutes)
                        {
                            analyzer.WriteResultFile(logfilename, outputDir);
                            dialogStr += analyzer.GetType() + "\n";
                        }
                        EditorUtility.DisplayDialog("Result", dialogStr, "ok");
                        analyzeExecutes.Clear();
                        logReader = null;
                        this.Repaint();
                        return;
                    }
                    foreach (var analyzer in this.analyzeExecutes)
                    {
                        try
                        {
                            analyzer.CollectData(frameData);
                        }
                        catch (System.Exception e)
                        {
                            Debug.LogError(e);
                        }
                    }
                    System.GC.Collect();
                    this.Repaint();
                }
            }
            catch (System.Exception e)
            {
                logReader = null;
                Debug.LogError(e);
            }
        }
示例#4
0
        void OnGUI()
        {
            EditorGUILayout.LabelField("Convert profiler log to csv");
            EditorGUILayout.BeginHorizontal();
            if (string.IsNullOrEmpty(filePath))
            {
                EditorGUILayout.LabelField("Select File");
            }
            else
            {
                EditorGUILayout.LabelField(this.filePath);
            }
            if (GUILayout.Button("File", GUILayout.Width(40.0f)))
            {
                this.filePath = EditorUtility.OpenFilePanelWithFilters("", "Select BinaryLogFile", new string[] { "profiler log", "data,raw" });
            }

            if (GUILayout.Button("Analyze", GUILayout.Width(100)))
            {
                if (string.IsNullOrEmpty(filePath) || !System.IO.File.Exists(filePath))
                {
                    Debug.LogError("No such File ");
                }
                else
                {
                    logReader = ProfilerLogUtil.CreateLogReader(filePath);
                    for (int i = 0; i < fileWriterFlags.Count; ++i)
                    {
                        if (this.fileWriterFlags[i].flag)
                        {
                            analyzeExecutes.Add(System.Activator.CreateInstance(fileWriterFlags[i].type) as IAnalyzeFileWriter);
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            if (logReader != null && 0.0f < logReader.Progress && logReader.Progress < 1.0f)
            {
                EditorGUILayout.LabelField("Progress " + logReader.Progress * 100.0f + "%");
            }
            else
            {
                for (int i = 0; i < fileWriterFlags.Count; ++i)
                {
                    this.fileWriterFlags[i].flag = EditorGUILayout.Toggle(this.fileWriterFlags[i].name, this.fileWriterFlags[i].flag);
                }
            }

            EditorGUILayout.LabelField("The results are in csv file.");
        }
 bool ExecuteFrame()
 {
     if (logReader == null)
     {
         return(false);
     }
     try
     {
         var frameData = logReader.ReadFrameData();
         if (isFirstFrame)
         {
             InitOutputPathInfo();
             SetAnalyzerInfo(analyzeExecutes, logReader);
             isFirstFrame = false;
         }
         if (frameData == null || forceStopRequest)
         {
             // write all result
             foreach (var analyzer in this.analyzeExecutes)
             {
                 analyzer.WriteResultFile(logfilename, outputDir);
             }
             requestDialogFlag = true;
             logReader         = null;
             return(false);
         }
         foreach (var analyzer in this.analyzeExecutes)
         {
             try
             {
                 analyzer.CollectData(frameData);
             }
             catch (System.Exception e)
             {
                 Debug.LogError(e);
             }
         }
         System.GC.Collect();
     }
     catch (System.Exception e)
     {
         logReader = null;
         Debug.LogError(e);
     }
     return(true);
 }
示例#6
0
 void Update()
 {
     try
     {
         if (logReader != null)
         {
             var frameData = logReader.ReadFrameData();
             if (frameData == null)
             {
                 // 終わったタイミングでcsv
                 string dialogStr = "Write to csv files\n";
                 foreach (var analyzer in this.analyzeExecutes)
                 {
                     string path = analyzer.ConvertPath(this.filePath);
                     analyzer.WriteResultFile(path);
                     dialogStr += path + "\n";
                 }
                 EditorUtility.DisplayDialog("Result", dialogStr, "ok");
                 analyzeExecutes.Clear();
                 logReader = null;
                 this.Repaint();
                 return;
             }
             foreach (var analyzer in this.analyzeExecutes)
             {
                 try
                 {
                     analyzer.CollectData(frameData);
                 }
                 catch (System.Exception e)
                 {
                     Debug.LogError(e);
                 }
             }
             System.GC.Collect();
             this.Repaint();
         }
     }
     catch (System.Exception e)
     {
         logReader = null;
         Debug.LogError(e);
     }
 }
 private void StartAnalyze()
 {
     logReader        = ProfilerLogUtil.CreateLogReader(filePath);
     isFirstFrame     = true;
     forceStopRequest = false;
     analyzeExecutes.Clear();
     for (int i = 0; i < fileWriterFlags.Count; ++i)
     {
         if (this.fileWriterFlags[i].flag)
         {
             var analyzer = System.Activator.CreateInstance(fileWriterFlags[i].type) as IAnalyzeFileWriter;
             analyzeExecutes.Add(analyzer);
         }
     }
     // start analyze
     if (isMultiThreadExecute)
     {
         var thread = new System.Threading.Thread(this.UpdateThread);
         thread.Start();
     }
 }
示例#8
0
        private static void SetAnalyzerInfo(List <IAnalyzeFileWriter> analyzeExecutes,
                                            ILogReaderPerFrameData logReader,
                                            string outDir, string inFile)
        {
            ProfilerLogFormat format = ProfilerLogFormat.TypeData;

            if (logReader.GetType() == typeof(UTJ.ProfilerReader.RawData.ProfilerRawLogReader))
            {
                format = ProfilerLogFormat.TypeRaw;
            }
            string unityVersion = Application.unityVersion;

            if (!string.IsNullOrEmpty(overrideUnityVersion))
            {
                unityVersion = overrideUnityVersion;
            }
            foreach (var analyzer in analyzeExecutes)
            {
                analyzer.SetInfo(format, unityVersion, logReader.GetLogFileVersion(), logReader.GetLogFilePlatform());
                analyzer.SetFileInfo(inFile, outDir);
            }
        }
示例#9
0
        public static int ProfilerToCsv(string inputFile, string outputDir, bool logFlag)
        {
            int retCode = NormalCode;

            if (string.IsNullOrEmpty(outputDir))
            {
                outputDir = System.IO.Path.GetDirectoryName(inputFile);
            }

            var logReader = ProfilerLogUtil.CreateLogReader(inputFile);

            currentReader = logReader;

            List <IAnalyzeFileWriter> analyzeExecutes = new List <IAnalyzeFileWriter>();

            analyzeExecutes.Add(new ThreadAnalyzeToFile());
            analyzeExecutes.Add(new WorkerJobAnalyzeToFile());
            analyzeExecutes.Add(new MainThreadAnalyzeToFile());
            analyzeExecutes.Add(new MemoryAnalyzeToFile());
            analyzeExecutes.Add(new RenderingAnalyzeToFile());
            analyzeExecutes.Add(new RenderThreadToFile());

            var frameData = logReader.ReadFrameData();

            if (frameData == null)
            {
                Debug.LogError("No FrameDataFile " + inputFile);
            }
            // Loop and execute each frame
            while (frameData != null)
            {
                try
                {
                    frameData = logReader.ReadFrameData();
                    if (logFlag)
                    {
                        System.Console.WriteLine("ReadFrame:" + frameData.frameIndex);
                    }
                }
                catch (System.Exception e)
                {
                    retCode = ReadErrorCode;
                    Debug.LogError(e);
                }

                foreach (var analyzer in analyzeExecutes)
                {
                    try
                    {
                        if (frameData != null)
                        {
                            analyzer.CollectData(frameData);
                        }
                    }catch (System.Exception e)
                    {
                        Debug.LogError(e);
                    }
                }
                System.GC.Collect();
            }
            foreach (var analyzer in analyzeExecutes)
            {
                string path = System.IO.Path.Combine(outputDir, analyzer.ConvertPath(System.IO.Path.GetFileName(inputFile)));
                analyzer.WriteResultFile(path);
            }

            return(retCode);
        }
示例#10
0
        void OnGUI()
        {
            EditorGUILayout.LabelField("Profiler BinLog Hack");
            EditorGUILayout.BeginHorizontal();
            this.filePath = EditorGUILayout.TextField(this.filePath);
            if (GUILayout.Button("File", GUILayout.Width(40.0f)))
            {
                this.filePath = EditorUtility.OpenFilePanelWithFilters("", "Select BinaryLogFile", new string[] { "profiler log", "data,raw" });
            }
            EditorGUILayout.EndHorizontal();
            {
                EditorGUILayout.LabelField("Concition");
                EditorGUILayout.BeginHorizontal();
                sampleNameCondition       = EditorGUILayout.TextField("sample name ", sampleNameCondition);
                this.stringCheckCondition = (EConditionType)EditorGUILayout.EnumPopup(this.stringCheckCondition);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("HierarchyMode");
                this.sampleCondition = (ESampleCondition)EditorGUILayout.EnumPopup(this.sampleCondition);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                this.conditionExecuteTime = EditorGUILayout.FloatField("Execute time(ms)", this.conditionExecuteTime);
                this.conditionAlloc       = EditorGUILayout.IntField("Alloc(byte)", conditionAlloc);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            if (!IsExecuting())
            {
                if (GUILayout.Button("Analyze", GUILayout.Width(100)))
                {
                    this.pageIndex = 1;
                    if (string.IsNullOrEmpty(filePath) || !System.IO.File.Exists(filePath))
                    {
                        Debug.LogError("No such File ");
                    }
                    else
                    {
                        logReader = ProfilerLogUtil.CreateLogReader(filePath);
                        columnList.Clear();
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Cancel", GUILayout.Width(100)))
                {
                    logReader.ForceExit();
                }
            }
            GUILayout.Label("");
            if (logReader != null && logReader.IsComplete)
            {
                if (GUILayout.Button("Write To CSV", GUILayout.Width(100)))
                {
                    SaveToCsv();
                }
            }
            EditorGUILayout.EndHorizontal();
            // execute now
            if (IsExecuting())
            {
                EditorGUILayout.LabelField("Progress " + logReader.Progress * 100.0f + "%");
            }
            else
            {
                this.ONGUIResultList();
                treeView.OnGUI();
            }
        }
示例#11
0
        public static int ProfilerToCsv(string inputFile, string outputDir, bool logFlag)
        {
            int retCode = NormalCode;

            if (string.IsNullOrEmpty(outputDir))
            {
                outputDir = System.IO.Path.GetDirectoryName(inputFile);
            }

            var logReader = ProfilerLogUtil.CreateLogReader(inputFile);

            currentReader = logReader;

            List <IAnalyzeFileWriter> analyzeExecutes = AnalyzerUtil.CreateAnalyzerInterfaceObjects();

            var frameData = logReader.ReadFrameData();

            SetAnalyzerInfo(analyzeExecutes, logReader);

            if (frameData == null)
            {
                Debug.LogError("No FrameDataFile " + inputFile);
            }
            // Loop and execute each frame
            while (frameData != null)
            {
                try
                {
                    frameData = logReader.ReadFrameData();
                    if (logFlag)
                    {
                        System.Console.WriteLine("ReadFrame:" + frameData.frameIndex);
                    }
                }
                catch (System.Exception e)
                {
                    retCode = ReadErrorCode;
                    Debug.LogError(e);
                }

                foreach (var analyzer in analyzeExecutes)
                {
                    try
                    {
                        if (frameData != null)
                        {
                            analyzer.CollectData(frameData);
                        }
                    }catch (System.Exception e)
                    {
                        Debug.LogError(e);
                    }
                }
                System.GC.Collect();
            }
            foreach (var analyzer in analyzeExecutes)
            {
                analyzer.WriteResultFile(System.IO.Path.GetFileName(inputFile), outputDir);
            }

            return(retCode);
        }