Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
                    }
                }
            }
        }
Beispiel #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));
 }
Beispiel #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);
 }
Beispiel #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));
 }
Beispiel #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();
Beispiel #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);
        }
Beispiel #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);
Beispiel #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);
Beispiel #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());
        }
Beispiel #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));
        }
Beispiel #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);
Beispiel #14
0
 public void OrderBy_TakeOne()
 {
     Perf_LinqTestBase.MeasureIteration(QuickSortWorstCase(10000).OrderBy(i => i).Take(1), 10);
 }
Beispiel #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();
Beispiel #16
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Reverse(), _consumer);
Beispiel #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));
        }
Beispiel #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);
Beispiel #19
0
 public int LastOrDefaultWithPredicate(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType)
 => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).LastOrDefault(x => x % 2 == 0);
Beispiel #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());
        }
Beispiel #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));
 }
Beispiel #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));
        }
Beispiel #23
0
 public void Repeat(int size, int iteration)
 {
     Perf_LinqTestBase.Measure <int>(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Repeat(0, size));
 }
Beispiel #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);
        }
Beispiel #25
0
 public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType)
 {
     Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Reverse());
 }
Beispiel #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);
Beispiel #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();