Ejemplo n.º 1
0
        private void CompareSorts(Func<int[], SortOrder, int[]> slowSort, Func<int[], SortOrder, int[]> fasterSort, int size = 10000)
        {
            var input1 = RandomArray(size);
            var input2 = RandomArray(size);

            int[] out1 = new int[size];
            int[] out2 = new int[size];

            var instrSlowSort = slowSort.Instrument<int[], SortOrder, int[]>();
            var instrFasterSort = fasterSort.Instrument<int[], SortOrder, int[]>();

            var slowTime = instrSlowSort(input1, SortOrder.Asc, out1);
            var fastTime = instrFasterSort(input2, SortOrder.Asc, out2);

            Assert.IsTrue(slowTime > fastTime);
        }