Beispiel #1
0
        private static void Test_Performance(int seed, string filename)
        {
            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)
            {
                MyFileArray fileArray = new MyFileArray(filename, k, seed);
                using (fileArray.fs = new FileStream(filename, FileMode.Open,
                                                     FileAccess.ReadWrite))
                {
                    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)
            {
                MyFileList fileArray = new MyFileList(filename, k, seed);
                using (fileArray.fs = new FileStream(filename, FileMode.Open,
                                                     FileAccess.ReadWrite))
                {
                    var watch = System.Diagnostics.Stopwatch.StartNew();
                    HeapSort(fileArray);
                    watch.Stop();
                    Console.WriteLine("Number of elements: " + k + " Time: " + watch.Elapsed);
                }
            }
        }
Beispiel #2
0
        public static void Test_File_Array_List(int seed)
        {
            int    n = 12;
            string filename;

            filename = @"mydataarray.dat";
            MyFileArray myfilearray = new MyFileArray(filename, n, seed);

            using (myfilearray.fs = new FileStream(filename, FileMode.Open,
                                                   FileAccess.ReadWrite))
            {
                Console.WriteLine("\n FILE ARRAY \n");
                myfilearray.Print(n);
                HeapSort(myfilearray);
                myfilearray.Print(n);
            }
            filename = @"mydatalist.dat";
            MyFileList myfilelist = new MyFileList(filename, n, seed);

            using (myfilelist.fs = new FileStream(filename, FileMode.Open,
                                                  FileAccess.ReadWrite))
            {
                Console.WriteLine("\n FILE LIST \n");
                myfilelist.Print(n);
                HeapSort(myfilelist);
                myfilelist.Print(n);
            }

            Test_Performance(seed, filename);
        }