예제 #1
0
        private static void IntTest()
        {
            try
            {
                var previousNbItem = nbItem;
                var previousSpread = spread;

                long dataSetBuildTime;
                long comparisonTime;

                ConsoleUtils.WriteTitle($"Int collection test", 1);
                ConsoleUtils.WriteLine();

                ConsoleUtils.Write($"Nb item (defaut = {nbItem}, 'q' to quit) : ");
                userInput = Console.ReadLine();
                if (userInput == "q")
                {
                    return;
                }
                var isUserInputValid = int.TryParse(userInput, out nbItem);
                if (!isUserInputValid)
                {
                    nbItem = previousNbItem;
                }

                ConsoleUtils.Write($"Dispersion (defaut = {spread}, 'q' to quit) : ");
                userInput = Console.ReadLine();
                if (userInput == "q")
                {
                    return;
                }
                isUserInputValid = int.TryParse(userInput, out spread);
                if (!isUserInputValid)
                {
                    spread = previousSpread;
                }

                sw.Restart();
                CreateIntTestData(nbItem, spread);
                sw.Stop();
                dataSetBuildTime = sw.ElapsedMilliseconds;

                ConsoleUtils.WriteLine();
                ConsoleUtils.WriteLine($"Test data creation :{dataSetBuildTime} ms");

                var ilc = new ListComparer <int>();
                sw.Restart();
                var comparison = ilc.Compare(intListRef, intListNew);
                Console.WriteLine();
                sw.Stop();
                comparisonTime = sw.ElapsedMilliseconds;
                sw.Start();
                ConsoleUtils.WriteLine($"Comparison :{comparisonTime} ms");
                Console.WriteLine();


                ConsoleUtils.WriteLine(ToString(comparison), InfoType.result);
                executionTime = dataSetBuildTime + comparisonTime;
            }
            catch (Exception e)
            {
                ConsoleUtils.WriteLine(e.ToStringEx(), InfoType.error);
            }
        }