Example #1
0
        public static void Write()
        {
            FileMaster master = new FileMaster("Profiler master.txt", "Profiler - ", 10);
            System.IO.TextWriter writer = master.GetTextWriter(DateTime.UtcNow.Ticks + ".csv");
            writer.WriteLine("Class Name, Method Name, Seconds, Invokes, Seconds per Invoke, Ratio of Sum, Ratio of Game Time");

            using (ProfileValues.m_lock.AcquireExclusiveUsing())
            {
                WriteBlock(writer, "Game Time,", new Stats() { TimeSpent = MyTimeSpan.FromSeconds(Globals.ElapsedTime.TotalSeconds) });
                WriteBlock(writer, "Sum,", ProfileValues.m_total);
                foreach (var pair in ProfileValues.m_profile)
                    WriteBlock(writer, pair.Key, pair.Value);
            }

            writer.Close();
        }
Example #2
0
        public static void Write()
        {
            FileMaster master = new FileMaster("Profiler master.txt", "Profiler - ", 10);

            System.IO.TextWriter writer = master.GetTextWriter(DateTime.UtcNow.Ticks + ".csv");
            writer.WriteLine("Class Name, Method Name, Seconds, Invokes, Seconds per Invoke, Worst Time, Ratio of Sum, Ratio of Game Time");

            using (ProfileValues.m_lock.AcquireExclusiveUsing())
            {
                WriteBlock(writer, "Game Time,", new Stats()
                {
                    TimeSpent = MyTimeSpan.FromSeconds(Globals.ElapsedTime.TotalSeconds)
                });
                WriteBlock(writer, "Sum,", ProfileValues.m_total);
                foreach (var pair in ProfileValues.m_profile)
                {
                    WriteBlock(writer, pair.Key, pair.Value);
                }
            }

            writer.Close();
        }
Example #3
0
        private static bool createLog()
        {
            if (MyAPIGateway.Utilities.FileExistsInLocalStorage(s_logMaster, typeof(Logger)))
            {
                for (int i = 0; i < 10; i++)
                    try
                    { deleteIfExists("log-" + i + ".txt"); }
                    catch { }
                FileMaster master = new FileMaster(s_logMaster, "log-", 10);
                Static.logWriter = master.GetTextWriter(DateTime.UtcNow.Ticks + ".txt");
            }
            else
            {
                for (int i = 0; i < 10; i++)
                    if (Static.logWriter == null)
                        try { Static.logWriter = MyAPIGateway.Utilities.WriteFileInLocalStorage("log-" + i + ".txt", typeof(Logger)); }
                        catch { }
                    else
                        try
                        { deleteIfExists("log-" + i + ".txt"); }
                        catch { }
            }

            return Static.logWriter != null;
        }
Example #4
0
        private void GetData()
        {
            m_fileMaster = new FileMaster("SaveDataMaster.txt", "SaveData - ", int.MaxValue);

            string serialized;
            if (MyAPIGateway.Utilities.GetVariable(SaveXml, out serialized))
            {
                m_data = MyAPIGateway.Utilities.SerializeFromXML<Builder_ArmsData>(serialized);
                if (m_data != null)
                {
                    m_logger.debugLog("ARMS data was imbeded in the save file proper", Logger.severity.DEBUG);
                    return;
                }
            }

            string identifier = LegacyIdentifier();
            if (identifier == null)
            {
                m_logger.debugLog("no identifier");
                return;
            }

            var reader = m_fileMaster.GetTextReader(identifier);
            if (reader != null)
            {
                m_logger.debugLog("loading from file: " + identifier);
                m_data = MyAPIGateway.Utilities.SerializeFromXML<Builder_ArmsData>(reader.ReadToEnd());
                reader.Close();
            }
            else
                m_logger.alwaysLog("Failed to open file reader for " + identifier);
        }