コード例 #1
0
ファイル: Program.cs プロジェクト: DmitryMI/AlgorithmAnalisis
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0] == "-t")
            {
                TestTime();
                Console.WriteLine("TESTING COMPLETED");
                Console.ReadKey();
                return;
            }

            if (args.Length > 0 && args[0] == "-rt")
            {
                TestTree();
                Console.WriteLine("TESTING COMPLETED");
                Console.ReadKey();
                return;
            }

            string a, b;

            Console.Write("Первая строка: ");
            a = Console.ReadLine();
            Console.Write("Вторая строка: ");
            b = Console.ReadLine();

            Console.WriteLine("\nРезультат: \n");

            foreach (StringDistance.Measure measure in Enum.GetValues(typeof(StringDistance.Measure)))
            {
                StringDistance distance = StringDistance.StringDistanceBuilder.GetInstance(measure, a, b);

                if (distance == null)
                {
                    continue;
                }

                System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();


                GC.Collect();

                stopwatch.Start();

                int result = distance.GetDistance();

                stopwatch.Stop();

                LetterMatrix matrix = distance.GetLetterMatrix();
                Console.WriteLine("Метод: " + distance.MethodName);
                Console.WriteLine("Значение: " + result);
                Console.WriteLine("Матрица: ");
                Console.Write(matrix.ToString());

                Console.WriteLine("Прошло времени (тиков): " + stopwatch.ElapsedTicks);
                Console.WriteLine("Прошло времени (секунд): " + stopwatch.ElapsedMilliseconds / 1000f);
                Console.WriteLine("\n");
            }

            Console.ReadKey();
        }