Exemplo n.º 1
0
        private static void Sort(ISortable sortable, IGeneratorItems generatorItems, int amount, FileService fileService)
        {
            fileService.Save(path, sortable.ToString());

            Console.WriteLine("---- Analyze " + amount + " ----" + sortable.ToString());
            TimeWatch timer = new TimeWatch();

            timer.Start();
            List <int> list = generatorItems.GetData(amount);

            Console.WriteLine("Time Loading List: " + timer.GetEllapsedMilliSeconds());

            timer.Restart();
            List <int> listOrderAsc  = new List <int>(list);
            List <int> listOrderDesc = new List <int>(list);

            Console.WriteLine("Time Loading List to Order Asc or Desc:" + timer.GetEllapsedMilliSeconds());

            timer.Restart();
            List <int> orderedList = OrderAsc(sortable, listOrderAsc);
            long       timeAsc     = timer.GetEllapsedMilliSeconds();

            Console.WriteLine("Time Ordering Asc:" + timer.GetEllapsedMilliSeconds());

            timer.Restart();
            List <int> orderedDescList = OrderDesc(sortable, listOrderDesc);
            long       timeDesc        = timer.GetEllapsedMilliSeconds();

            Console.WriteLine("Time Ordering Desc:" + timer.GetEllapsedMilliSeconds());

            fileService.Save(path, Environment.NewLine + $"Amount:{amount},TimeAsc:{timeAsc}, TimeDesc:{timeDesc}");
        }