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);
        }