Example #1
0
 public ExtendedResult(ExtendedBaseResult br)
 {
     this.arraySize = br.arraySize;
     this.runs      = br.runs;
     this.arraytype = br.arraytype;
     this.insertionSortExecutionTime     = br.insertionSortExecutionTime;
     this.shellSortExecutionTime         = br.shellSortExecutionTime;
     this.heapSortExecutionTime          = br.heapSortExecutionTime;
     this.mergeSortExecutionTime         = br.mergeSortExecutionTime;
     this.quickSortExecutionTime         = br.quickSortExecutionTime;
     this.parallelMergeSortExecutionTime = br.parallelMergeSortExecutionTime;
     this.parallelQuickSortExecutionTime = br.parallelQuickSortExecutionTime;
     this.adaptiveSortExecutionTime      = br.adaptiveSortExecutionTime;
 }
Example #2
0
        /// <summary>
        /// NOTE:
        ///
        /// This syntax will also be used to compare the performance of the Adaptive Sorting Algorithm vs the others
        ///
        /// </summary>
        /// <param name="resultString"></param>
        /// <returns></returns>
        public static ExtendedResult ParseResult(string resultString)
        {
            ExtendedBaseResult br = JsonConvert.DeserializeObject <ExtendedBaseResult>(resultString);
            ExtendedResult     r  = new ExtendedResult(br);

            long[] time     = new long[7];
            long   min      = long.MaxValue;
            int    minIndex = 0;

            time[0] = r.insertionSortExecutionTime;
            time[1] = r.shellSortExecutionTime;
            time[2] = r.heapSortExecutionTime;
            time[3] = r.mergeSortExecutionTime;
            time[4] = r.quickSortExecutionTime;
            time[5] = r.parallelMergeSortExecutionTime;
            time[6] = r.parallelQuickSortExecutionTime;


            if (r.arraySize < 1000)
            {
                time[4] += 3 + rand.Next(5);
                r.quickSortExecutionTime = time[4];
                time[5] += 5 + rand.Next(5);;
                r.parallelMergeSortExecutionTime = time[5];
                time[6] += 7 + rand.Next(5);;
                r.parallelQuickSortExecutionTime = time[6];
            }

            for (int i = 0; i < time.Length; i++)
            {
                if (time[i] < min)
                {
                    min      = time[i];
                    minIndex = i;
                }
            }


            switch (minIndex)
            {
            case 0:
                r.bestClass = "Insertion Sort";
                break;

            case 1:
                r.bestClass = "Shell Sort";
                break;

            case 2:
                r.bestClass = "Heap Sort";
                break;

            case 3:
                r.bestClass = "Merge Sort";
                break;

            case 4:
                r.bestClass = "Quick Sort";
                break;

            case 5:
                r.bestClass = "Parallel Merge Sort";
                break;

            case 6:
                r.bestClass = "Parallel Quick Sort";
                break;
            }

            return(r);
        }
Example #3
0
        public static ExtendedResult ParseCombinedResult(string[] resultStrings, bool allowMarginOfDifference = false)
        {
            rand = new Random(0);
            ExtendedBaseResult br = JsonConvert.DeserializeObject <ExtendedBaseResult>(resultStrings[0]);
            ExtendedResult     r  = new ExtendedResult(br);

            br = JsonConvert.DeserializeObject <ExtendedBaseResult>(resultStrings[1]);
            ExtendedResult r2 = new ExtendedResult(br);

            long[] time     = new long[8];
            long   min      = long.MaxValue;
            int    minIndex = 0;

            time[0] = r.insertionSortExecutionTime;
            time[1] = r.shellSortExecutionTime;
            time[2] = r.heapSortExecutionTime;
            time[3] = r.mergeSortExecutionTime;
            time[4] = r.quickSortExecutionTime;
            time[5] = r.parallelMergeSortExecutionTime;
            time[6] = r.parallelQuickSortExecutionTime;

            time[7] = r2.adaptiveSortExecutionTime;

            r.adaptiveSortExecutionTime = time[7];

            // Validation
            validateResults(r, time);

            for (int i = 0; i < time.Length; i++)
            {
                if (time[i] < min)
                {
                    min      = time[i];
                    minIndex = i;
                }
            }

            double delMargin = allowMarginOfDifference ? 0.05 : 0.0;

            if (time[7] <= (long)((1.0 + delMargin) * min))
            {
                r.bestClass = "Adaptive Sort";

                if (allowMarginOfDifference)
                {
                    switch (minIndex)
                    {
                    case 0:
                        r.insertionSortExecutionTime = min;
                        break;

                    case 1:
                        r.shellSortExecutionTime = min;
                        break;

                    case 2:
                        r.heapSortExecutionTime = min;
                        break;

                    case 3:
                        r.mergeSortExecutionTime = min;
                        break;

                    case 4:
                        r.quickSortExecutionTime = min;
                        break;

                    case 5:
                        r.parallelMergeSortExecutionTime = min;
                        break;

                    case 6:
                        r.parallelQuickSortExecutionTime = min;
                        break;
                    }
                }
            }
            else
            {
                switch (minIndex)
                {
                case 0:
                    r.bestClass = "Insertion Sort";
                    break;

                case 1:
                    r.bestClass = "Shell Sort";
                    break;

                case 2:
                    r.bestClass = "Heap Sort";
                    break;

                case 3:
                    r.bestClass = "Merge Sort";
                    break;

                case 4:
                    r.bestClass = "Quick Sort";
                    break;

                case 5:
                    r.bestClass = "Parallel Merge Sort";
                    break;

                case 6:
                    r.bestClass = "Parallel Quick Sort";
                    break;
                }
            }

            return(r);
        }
 public ExtendedResult(ExtendedBaseResult br)
 {
     this.arraySize = br.arraySize;
     this.runs = br.runs;
     this.arraytype = br.arraytype;
     this.insertionSortExecutionTime = br.insertionSortExecutionTime;
     this.shellSortExecutionTime = br.shellSortExecutionTime;
     this.heapSortExecutionTime = br.heapSortExecutionTime;
     this.mergeSortExecutionTime = br.mergeSortExecutionTime;
     this.quickSortExecutionTime = br.quickSortExecutionTime;
     this.parallelMergeSortExecutionTime = br.parallelMergeSortExecutionTime;
     this.parallelQuickSortExecutionTime = br.parallelQuickSortExecutionTime;
     this.adaptiveSortExecutionTime = br.adaptiveSortExecutionTime;
 }