예제 #1
0
        private static void RunTest_ArraySort_Random(
            int length, int loopsPerRun)
        {
            var benchmark = new ArraySortPerfTest(
                ArraySortPerfTestUtils.InitRandom,
                Array.Sort,
                length,
                loopsPerRun);

            double msPerSort = benchmark.Run();

            Console.WriteLine($"Array.Sort() [Random]:\t{msPerSort} ms / sort");
        }
예제 #2
0
        private static void RunTest_TimSort_Natural(
            int length, int loopsPerRun)
        {
            // Alloc a re-usable working array for timsort.
            int[] workArr = new int[50000];

            // Create wrapper for timsort that provides the working array.
            void timsort(int[] arr)
            {
                TimSort <int> .Sort(arr, 0, arr.Length, workArr);
            }

            var benchmark = new ArraySortPerfTest(
                ArraySortPerfTestUtils.InitNatural,
                timsort,
                length,
                loopsPerRun);

            double msPerSort = benchmark.Run();

            Console.WriteLine($"TimSort<int>.Sort [Natural]:\t{msPerSort} ms / sort");
        }