Example #1
0
 public static IEnumerable <object[]> AggregateExceptionData(int[] counts)
 {
     foreach (object[] results in UnorderedSources.Ranges(counts.Cast <int>()))
     {
         Labeled <ParallelQuery <int> > query = (Labeled <ParallelQuery <int> >)results[0];
         if (query.ToString().StartsWith("Partitioner"))
         {
             yield return(new object[] { Labeled.Label(query.ToString(), Partitioner.Create(UnorderedSources.GetRangeArray(0, (int)results[1]), false).AsParallel()), results[1] });
         }
         else if (query.ToString().StartsWith("Enumerable.Range"))
         {
             yield return(new object[] { Labeled.Label(query.ToString(), new StrictPartitioner <int>(Partitioner.Create(Enumerable.Range(0, (int)results[1]), EnumerablePartitionerOptions.None), (int)results[1]).AsParallel()), results[1] });
         }
         else
         {
             yield return(results);
         }
     }
 }
Example #2
0
 public static IEnumerable <object[]> NotLoadBalancedDegreeData(object[] counts, object[] degrees)
 {
     foreach (object[] results in DegreeData(counts, degrees))
     {
         Labeled <ParallelQuery <int> > query = (Labeled <ParallelQuery <int> >)results[0];
         if (query.ToString().StartsWith("Partitioner"))
         {
             yield return(new object[] { Labeled.Label(query.ToString(), Partitioner.Create(UnorderedSources.GetRangeArray(0, (int)results[1]), false).AsParallel()), results[1], results[2] });
         }
         else if (query.ToString().StartsWith("Enumerable.Range"))
         {
             yield return(new object[] { Labeled.Label(query.ToString(), new StrictPartitioner <int>(Partitioner.Create(Enumerable.Range(0, (int)results[1]), EnumerablePartitionerOptions.NoBuffering), (int)results[1]).AsParallel()), results[1], results[2] });
         }
         else
         {
             yield return(results);
         }
     }
 }
        public static void GetEnumerator(Labeled <ParallelQuery <int> > labeled, int count)
        {
            int seen = 0;
            IEnumerator <int> enumerator = labeled.Item.GetEnumerator();

            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                Assert.Equal(seen++, enumerator.Current);
            }
            Assert.Equal(count, seen);
        }
        public static void GetEnumerator_Unordered(Labeled <ParallelQuery <int> > labeled, int count)
        {
            IntegerRangeSet   seen       = new IntegerRangeSet(0, count);
            IEnumerator <int> enumerator = labeled.Item.GetEnumerator();

            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                seen.Add(enumerator.Current);
            }
            seen.AssertComplete();
        }
Example #5
0
 public static Labeled <ParallelQuery <T> > Order <T>(this Labeled <ParallelQuery <T> > query)
 {
     return(Label(query.ToString() + "-Ordered", query.Item.AsOrdered()));
 }