Exemplo n.º 1
0
        public void Cast_SameType(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            Func <IEnumerable <int>, IEnumerable <int> > linqApply = col => col.Cast <int>();
            int val = 1;

            Perf_LinqTestBase.Measure <int, int>(10, 5, val, wrapType, linqApply);
        }
Exemplo n.º 2
0
        public void Cast_ToBaseClass(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            Func <IEnumerable <ChildClass>, IEnumerable <BaseClass> > linqApply = col => col.Cast <BaseClass>();
            ChildClass val = new ChildClass()
            {
                Value = 1, ChildValue = 2
            };

            Perf_LinqTestBase.Measure <ChildClass, BaseClass>(10, 5, val, wrapType, linqApply);
        }
Exemplo n.º 3
0
        public void Contains_FirstElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable<int> source = Perf_LinqTestBase.Wrap(Enumerable.Range(0, size).ToArray(), wrapType);

            foreach (BenchmarkIteration iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    for (int i = 0; i < iterationCount; i++)
                    {
                        source.Contains(0);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void WhereSelect(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Where(o => o >= 0).Select(o => o + 1));
 }
Exemplo n.º 5
0
 public void ToDictionary(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     int[] array = Enumerable.Range(0, size).ToArray();
     Perf_LinqTestBase.MeasureMaterializationToDictionary <int>(Perf_LinqTestBase.Wrap(array, wrapType), iteration);
 }
Exemplo n.º 6
0
 public void SkipTake(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Skip(1).Take(size - 2));
 }
Exemplo n.º 7
0
 public int WhereLastOrDefault(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x % 2 == 0).LastOrDefault();
Exemplo n.º 8
0
        [ArgumentsSource(nameof(IterationSizeWrapperData))] // for some reason the size and iteration arguments are ignored for this benchmark
        public void Cast_SameType(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_intArrayOfTenElements, wrapType);

            source.Cast <int>().Consume(_consumer);
        }
Exemplo n.º 9
0
 public void WhereSelect(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Where(o => o >= 0).Select(o => o + 1), _consumer);
Exemplo n.º 10
0
 public int FirstWithPredicate_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).First(x => x >= size - 1);
Exemplo n.º 11
0
        public int[] ToArray(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.ToArray());
        }
Exemplo n.º 12
0
        public int FirstWithPredicate_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.First(x => x >= size - 1));
        }
Exemplo n.º 13
0
 public void TakeLastFull(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.TakeLast(size - 1), _consumer);
Exemplo n.º 14
0
 public void OrderBy_TakeOne()
 {
     Perf_LinqTestBase.MeasureIteration(QuickSortWorstCase(10000).OrderBy(i => i).Take(1), 10);
 }
Exemplo n.º 15
0
 public int WhereFirstOrDefault_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x >= size - 1).FirstOrDefault();
Exemplo n.º 16
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Reverse(), _consumer);
Exemplo n.º 17
0
        public Dictionary <int, int> ToDictionary(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.ToDictionary(key => key));
        }
Exemplo n.º 18
0
 public void SkipTake(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Skip(1).Take(size - 2), _consumer);
Exemplo n.º 19
0
 public int LastOrDefaultWithPredicate(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).LastOrDefault(x => x % 2 == 0);
Exemplo n.º 20
0
        public List <int> SelectToList(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.Select(i => i).ToList());
        }
Exemplo n.º 21
0
 public void OrderByThenBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.OrderBy(o => - o).ThenBy(o => o));
 }
Exemplo n.º 22
0
        public bool Contains_FirstElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.Contains(0));
        }
Exemplo n.º 23
0
 public void Repeat(int size, int iteration)
 {
     Perf_LinqTestBase.Measure <int>(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Repeat(0, size));
 }
Exemplo n.º 24
0
        [ArgumentsSource(nameof(IterationSizeWrapperData))] // for some reason the size and iteration arguments are ignored for this benchmark
        public void Cast_ToBaseClass(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <ChildClass> source = Perf_LinqTestBase.Wrap(_childClassArrayOfTenElements, wrapType);

            source.Cast <BaseClass>().Consume(_consumer);
        }
Exemplo n.º 25
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Reverse());
 }
Exemplo n.º 26
0
 public void OrderBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.OrderBy(o => - o), _consumer);
Exemplo n.º 27
0
 public bool WhereAny_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x >= size - 1).Any();