Exemplo n.º 1
0
        public Result Run(int count)
        {
            Result avg = new Result();

            // Clone the array multiple times so both in-place and non-in-place algorithms can run
            // without the array copy skewing the results.
            results = new int[count][];
            for (int i = 0; i < count; ++i)
            {
                results[i] = new int[originalArray.Length];
                System.Array.Copy(originalArray, results[i], originalArray.Length);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            System.GC.Collect();
            sw.Start();

            for (int i = 0; i < count; ++i)
            {
                DoSort(results[i], avg);
            }

            sw.Stop();
            avg.elapsedTime = (double)sw.ElapsedMilliseconds;
            avg.Divide(count);

            return avg;
        }