Example #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);
        }
Example #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);
        }
Example #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);
                    }
                }
            }
        }
Example #4
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);
Example #5
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Reverse(), _consumer);
Example #6
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));
 }
Example #7
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);
 }
Example #8
0
 public int WhereLastOrDefault(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x % 2 == 0).LastOrDefault();
Example #9
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);
        }
Example #10
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);
Example #11
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));
        }
Example #12
0
        public int[] ToArray(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
        {
            IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType);

            return(source.ToArray());
        }
Example #13
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));
        }
Example #14
0
 public void TakeLastFull(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.TakeLast(size - 1), _consumer);
Example #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();
Example #16
0
 public int FirstWithPredicate_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).First(x => x >= size - 1);
Example #17
0
 public int LastOrDefaultWithPredicate(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).LastOrDefault(x => x % 2 == 0);
Example #18
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());
        }
Example #19
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));
 }
Example #20
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));
        }
Example #21
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Reverse());
 }
Example #22
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);
        }
Example #23
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));
 }
Example #24
0
 public void OrderBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.OrderBy(o => - o), _consumer);
Example #25
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();