public static ISorterEval FullTest(this ISorter sorter)
 {
     return(sorter.Sort(Switchable.AllSwitchablesForKeyCount(sorter.KeyCount)
                        .ToSwitchableGroup(
                            guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(sorter.KeyCount),
                            keyCount: sorter.KeyCount)));
 }
Esempio n. 2
0
        public IEnumerable <IEnumerable <ISorterEval> > RandomSorterTests(int seed, int keyCount,
                                                                          int switchLength)
        {
            KeyPairSwitchSet.Make <uint>(keyCount);
            var testSet = Switchable.AllSwitchablesForKeyCount(keyCount).ToSwitchableGroup(
                guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(keyCount),
                keyCount: keyCount);

            foreach (var chunk in RandomSorters(seed, keyCount, switchLength).Chunk(16))
            {
                yield return(chunk.AsParallel().Select(s => s.Sort(testSet)));
            }
        }
Esempio n. 3
0
        //public static ICompPool ToCompPoolParallel(
        //    this IEnumerable<ISorter> sorters
        //)
        //{
        //    var sortersList = sorters.ToList();
        //    var keyCount = sortersList[0].KeyCount;
        //    KeyPairSwitchSet.Make<uint>(keyCount);
        //    var switchables = Switchable.AllSwitchablesForKeyCount(keyCount).ToSwitchableGroup
        //        (
        //            guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(keyCount),
        //            keyCount: keyCount
        //        );

        //    return new CompPoolImpl(
        //            sorterEvals: sortersList.AsParallel().Select(s => s.Sort(switchables)),
        //            keyCount: keyCount
        //        );
        //}

        public static ICompPool AddSorterEvalsParallel(this ICompPool compPool,
                                                       IEnumerable <ISorter> sorters)
        {
            KeyPairSwitchSet.Make <uint>(compPool.KeyCount);
            var switchables = Switchable.AllSwitchablesForKeyCount(compPool.KeyCount).ToSwitchableGroup
                              (
                guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(compPool.KeyCount),
                keyCount: compPool.KeyCount
                              );

            return(new CompPoolImpl(
                       sorterEvals: compPool.SorterEvals.Concat(sorters.AsParallel().Select(s => s.Sort(switchables))),
                       keyCount: compPool.KeyCount
                       ));
        }