Esempio n. 1
0
        static void Main(string[] args)
        {
#if DEBUG_TIME
            //TimingTest();
            TimingTestCompare();
            return;
#endif
#if DEBUG
            DateTime tStart = DateTime.Now;
            string dRom = "4dwarrio";
#endif
            bool isLegacyStart = false;
            string cmdLine = string.Empty;
            CsvParser parser = new CsvParser();
            parser.separator = ' ';

#if DEBUG_READ
            cmdLine = string.Format(@"-ra ""E:\Stuff\Nick Test\hi\{0}.hi""", dRom);
#elif DEBUG_LIST
            cmdLine = string.Format(@"-lp ""E:\Stuff\Nick Test\mame.exe""");
#elif DEBUG_WRITE
            string dToWrite = "1 62000 NLA";
            cmdLine = string.Format(@"-w ""E:\Stuff\Nick Test\hi\{0}.hi"" {1}", dRom, dToWrite);
#endif

            if (args.Length > 0)
                isLegacyStart = true;

            if (isLegacyStart)
            {
#if !DEBUG
                cmdLine = "\"" + string.Join("\" \"", args) + "\"";
#endif
                StringCollection commands = parser.ParseCsv(cmdLine);

                //Put anything that would only need to be run once in the initialize function.
#if DEBUG_READ
                Initialize(ConsoleFlags.ReadAll, dRom);
#else
                if (commands.Count > 1)
                    Initialize(GetFlagFromString(commands[0].ToLower()), Path.GetFileNameWithoutExtension(commands[1]));
                else
                    Initialize(ConsoleFlags.None, string.Empty);
            
                PerformCommand(commands);
                return;
                
#endif
            }
            else
                Initialize(ConsoleFlags.None, string.Empty);
            
#if DEBUG
            DateTime tAIStart = DateTime.Now;
#endif

            Console.WriteLine("HiToText initialized, please enter command. (-h for help)");
            Console.Write(">");
#if DEBUG
            if (true)
            {
#else
            while (!(cmdLine = Console.ReadLine()).Equals("-q"))
            {
#endif
                PerformCommand(parser.ParseCsv(cmdLine));

#if DEBUG
                DateTime tAIEnd = DateTime.Now;
                double totalAITimems = tAIEnd.Subtract(tAIStart).TotalMilliseconds;
                Console.WriteLine(string.Format("Inner operation took {0}ms to complete.", totalAITimems.ToString("#.00#")));
#else
                Console.Write(">");
#endif
            }

            Console.WriteLine("Exitting HiToText.");

#if DEBUG
            DateTime tEnd = DateTime.Now;
            double totalTimems = tEnd.Subtract(tStart).TotalMilliseconds;
            Console.WriteLine(string.Format("Operation took {0}ms to complete.", totalTimems.ToString("#.00#")));
#endif
        }
Esempio n. 2
0
        private static void TimingTestCompare()
        {
            List<string> toWrite = new List<string>();
            List<double> cTimes = new List<double>();
            
            List<string> hiFiles = new List<string>(Directory.GetFiles(@"E:\Stuff\Nick Test\hi\strict\"));

            for (int i = 0; i < 50; i++)
            {
                string dRom =
                    Path.GetFileName(hiFiles[new Random(DateTime.Now.Millisecond).Next(0, hiFiles.Count)]);
                DateTime cStart = DateTime.Now;
                CsvParser parser = new CsvParser();
                parser.separator = ' ';
                string cmdLine = string.Format(@"-ra ""E:\Stuff\Nick Test\hi\{0}""", dRom);
                Initialize(ConsoleFlags.ReadAll, Path.GetFileNameWithoutExtension(dRom));
                PerformCommand(parser.ParseCsv(cmdLine));
                DateTime cEnd = DateTime.Now;

                double cTimems = cEnd.Subtract(cStart).TotalMilliseconds;
                toWrite.Add(string.Format("Reading {0} took {1}ms to complete.", dRom, cTimems.ToString("#.00#")));
                cTimes.Add(cTimems);
            }

            foreach (string w in toWrite)
                Console.WriteLine(w);

            double cTotal = 0.00;
            foreach (double d in cTimes)
                cTotal += d;

            Console.WriteLine(
                string.Format(
                    "Average time for {0} reads: {1}ms",
                        cTimes.Count.ToString(),
                        (cTotal / ((double)cTimes.Count)).ToString()));
        }