Пример #1
0
        static void Main(string[] args)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            List <string> wordstream = new List <string>();

            wordstream.AddRange(WordTools.SampleWordStream);

            for (int i = 0; i < 1000000 - wordstream.Count; i++)
            {
                wordstream.Add(WordTools.GetRandomWord());
            }

            IEnumerable <string> ranking = _wordFinder.Find(wordstream);

            stopwatch.Stop();
            var elapsedTicks        = stopwatch.ElapsedTicks;
            var elapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            System.Console.WriteLine();
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine("SEEDED WORDS:");
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine();

            foreach (string word in WordTools.SampleWordStream)
            {
                System.Console.WriteLine(word);
            }

            System.Console.WriteLine();
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine("MATRIX:");
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine();

            MatrixTools.PrintMatrix(MatrixTools.GetIEnumerableMatrix(_matrixSize, _matrix));

            System.Console.WriteLine();
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine("RANKING:");
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine();

            foreach (string word in ranking)
            {
                System.Console.WriteLine(word);
            }

            System.Console.WriteLine();
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine("STATS:");
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine();
            System.Console.WriteLine($"Elapsed Milliseconds: {elapsedMilliseconds}");
            System.Console.WriteLine($"Elapsed Ticks: {elapsedTicks}");
            System.Console.WriteLine();
        }
Пример #2
0
        public void Find_Should_Return_Results_In_Less_Than_One_Second_For_One_Million_Words()
        {
            List <string> wordstream = new List <string>();

            wordstream.AddRange(WordTools.SampleWordStream);

            for (int i = 0; i < 1000000 - wordstream.Count; i++)
            {
                wordstream.Add(WordTools.GetRandomWord());
            }

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            IEnumerable <string> results = _wordFinder.Find(wordstream);

            stopWatch.Stop();

            Assert.True(stopWatch.ElapsedMilliseconds < 1000);
        }