Пример #1
0
        public static void Time(SortBase sort, string sortType, int count = 100, int length = 10000)
        {
            long total = 0;

            for (int j = 0; j < count; j++)
            {
                int[]     a     = GetArray(sortType, length);
                Stopwatch watch = Stopwatch.StartNew();
                sort.Sort(a);
                long elapsed = watch.ElapsedMilliseconds;
                total += elapsed;
            }
            string.Format("sort {0} elements need {1} ms in average of {2}", length, total / count, sortType).Dump();
        }
Пример #2
0
        public static void Run(SortBase sort, string sortType)
        {
            int length = 10;

            int[] a = GetArray(sortType, length);
            string.Join(",", a).Dump();
            sort.Sort(a);
            Assert(a).Dump();
            string.Join(",", a).Dump();

            System.Console.WriteLine("compare content : {0}", sort.Statistic.CompareContent);
            System.Console.WriteLine("exchange content : {0}", sort.Statistic.ExchangeContent);
            System.Console.WriteLine("access content : {0}", sort.Statistic.AccessContent);
        }