Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // join unicode
            Console.OutputEncoding = Encoding.Unicode;

            string testStr = "The “C# Professional” course includes the topics " +
                             "I discuss in my CLR via C# book and teaches how the CLR works " +
                             "thereby showing you how to develop applications and reusable " +
                             "components for the .NET Framework.";

            // testing with timer
#if test
            Stopwatch timer  = new Stopwatch();
            double[]  result = new double[2];
#endif

            #region Variant 1
#if false
#if test
            timer.Start();
#endif
            // analysis of string and show result
            var v1 = TextAnalysis.GetGroupOfWords0(testStr);
#if test
            timer.Stop();
            result[0] = timer.Elapsed.TotalSeconds;
#endif
            Console.WriteLine();
            v1.ToPresent();
#endif
            #endregion

            #region Variant 2
#if false
            // create file for testing
            // CreateTestFile();

            // when, the user want to fall the *.txt file
            if (args.Length > 0)
            {
                AnalysisFile(args[0]);
            }
#endif
            #endregion

            #region Variant 3
#if true
#if test
            timer.Restart();
#endif
            // analysis of string and show result
            var v3 = TextAnalysis.GetGroupOfWords1(testStr);//.ToPresent();
#if test
            timer.Stop();
            result[1] = timer.Elapsed.TotalSeconds;
#endif
            Console.WriteLine();
            v3.ToPresent();
#if test
            Console.WriteLine();
            Console.WriteLine($"Variant 1: " + result[0]);
            Console.WriteLine($"Variant 3: " + result[1]);
#endif
#endif
            #endregion

            // delay
            Console.ReadKey(true);
        }