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); }
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); }
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); } } } }
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)); }
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); }
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)); }
public int WhereLastOrDefault(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x % 2 == 0).LastOrDefault();
[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); }
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);
public int FirstWithPredicate_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).First(x => x >= size - 1);
public int[] ToArray(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) { IEnumerable <int> source = Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType); return(source.ToArray()); }
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)); }
public void TakeLastFull(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.TakeLast(size - 1), _consumer);
public void OrderBy_TakeOne() { Perf_LinqTestBase.MeasureIteration(QuickSortWorstCase(10000).OrderBy(i => i).Take(1), 10); }
public int WhereFirstOrDefault_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x >= size - 1).FirstOrDefault();
public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.Reverse(), _consumer);
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)); }
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);
public int LastOrDefaultWithPredicate(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).LastOrDefault(x => x % 2 == 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()); }
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)); }
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)); }
public void Repeat(int size, int iteration) { Perf_LinqTestBase.Measure <int>(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Repeat(0, size)); }
[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); }
public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) { Perf_LinqTestBase.Measure <int>(size, iteration, wrapType, col => col.Reverse()); }
public void OrderBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Measure(_sizeToPreallocatedArray[size], wrapType, col => col.OrderBy(o => - o), _consumer);
public bool WhereAny_LastElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) => Perf_LinqTestBase.Wrap(_sizeToPreallocatedArray[size], wrapType).Where(x => x >= size - 1).Any();