private static void Test_Performance(int seed)
        {
            Console.WriteLine("---------------------------------");
            Console.WriteLine("Performance test");
            int[] amount = { 100, 200, 400, 800, 1600, 3200, 6400, 12800 };
            Console.WriteLine("Array Test");
            foreach (var k in amount)
            {
                MyDataArray fileArray = new MyDataArray(k, seed);

                var watch = System.Diagnostics.Stopwatch.StartNew();
                HeapSort(fileArray);
                watch.Stop();
                Console.WriteLine("Number of elements: " + k + " Time: " + watch.Elapsed);
            }

            Console.WriteLine("List Test");
            foreach (var k in amount)
            {
                MyDataList fileArray = new MyDataList(k, seed);

                var watch = System.Diagnostics.Stopwatch.StartNew();
                HeapSort(fileArray);
                watch.Stop();
                Console.WriteLine("Number of elements: " + k + " Time: " + watch.Elapsed);
            }
        }
示例#2
0
        public static void AnalysisArray_List(int seed, int kiek)
        {
            int n = duomskc;

            Console.WriteLine("Array HeapSort");
            Console.WriteLine("N         RunTime");
            for (int i = 0; i < kiek; i++)
            {
                MyDataArray myarr = new MyDataArray(n, seed);
                Stopwatch   timer = new Stopwatch();
                timer.Start();
                Program.HeapSortArray.HeapSortas(myarr);
                timer.Stop();
                //myarr.Print(n);
                Console.WriteLine("{0,-10}{1}", n, timer.Elapsed);
                n = n * 2;
            }
            Console.WriteLine();
            n = duomskc;
            Console.WriteLine("List HeapSort");
            Console.WriteLine("N         RunTime");
            for (int i = 0; i < kiek; i++)
            {
                MyDataList mylist = new MyDataList(n, seed);
                Stopwatch  timer  = new Stopwatch();
                timer.Start();
                Program.HeapSortList.HeapSortas(mylist);
                timer.Stop();
                //mylist.Print(n);
                Console.WriteLine("{0,-10}{1}", n, timer.Elapsed);
                n = n * 2;
            }
            Console.WriteLine();
        }
        public static void Test_Array_List(int seed)
        {
            int         n       = 10;
            MyDataArray myarray = new MyDataArray(n, seed);

            Console.WriteLine("\n ARRAY \n");
            myarray.Print(n);
            HeapSort(myarray);
            myarray.Print(n);

            MyDataList mylist = new MyDataList(n, seed);

            Console.WriteLine("\n LIST \n");
            mylist.Print(n);
            HeapSort(mylist);
            mylist.Print(n);

            Test_Performance(seed);
        }
示例#4
0
        public static void TestArray_List(int seed)
        {
            int         n       = 12;
            MyDataArray myArray = new MyDataArray(n, seed);

            Console.WriteLine("---Array---");
            myArray.Print(n);
            Console.WriteLine();
            Console.WriteLine("---HeapSortedArray---");
            HeapSortArray.HeapSortas(myArray);
            myArray.Print(n);
            Console.WriteLine();
            MyDataList myList = new MyDataList(n, seed);

            Console.WriteLine("---List---");
            myList.Print(n);
            Console.WriteLine();
            Console.WriteLine("---HeapSortedList---");
            HeapSortList.HeapSortas(myList);
            myList.Print(n);
            Console.WriteLine();
        }