Example #1
0
        private static void ReportAllSubscriptionCounts()
        {
            //var informationObjects = GetAllInformationObjects(io => SubscribeSupport.GetSubscriptions(io.RelativeLocation) != null).ToArray();
            long memBefore = GC.GetTotalMemory(false);
            string interestGroupLocation = "grp/" + RenderWebSupport.DefaultGroupID + "/";
            var informationObjects = StorageSupport.CurrActiveContainer.GetInformationObjects(interestGroupLocation, null, io =>  io is AddressAndLocation &&
                SubscribeSupport.GetSubscriptions(io.RelativeLocation) != null).ToArray();

            int currMaxSubs = 0;
            int currMaxDistinct = 0;
            Dictionary<string, SubcriptionGraphItem> lookupDictionary = new Dictionary<string, SubcriptionGraphItem>();
            //lookupDictionary = null;
            DateTime before = DateTime.Now;
            foreach(var iObject in informationObjects)
            {
                int subCount = GetTotalSubscriberCount(iObject, ref currMaxSubs, ref currMaxDistinct, lookupDictionary);
            }
            DateTime after = DateTime.Now;
            var executionOrder = lookupDictionary.GetExecutionOrder();
            var subscriptionsToExecute = executionOrder.SelectMany(exec => exec.GetMySubscriptionsFromTargets()).ToArray();
            DateTime afterWards = DateTime.Now;
            TimeSpan duration1 = after - before;
            TimeSpan duration2 = afterWards - before;
            var filteredListToExecute =
                SubscribeSupport.GetSubscriptionChainItemsInOrderOfExecution(
                    informationObjects.Select(io => io.RelativeLocation).ToArray());
            long memAfter = GC.GetTotalMemory(false);
        }
Example #2
0
 public static Subscription[] GetSubscriptionChainItemsInOrderOfExecution(string[] subscriptionTargetList)
 {
     List<Subscription> subscriptions = new List<Subscription>();
     Dictionary<string, SubcriptionGraphItem> lookupDictionary = new Dictionary<string, SubcriptionGraphItem>();
     foreach(var subTarget in subscriptionTargetList)
     {
         var subscriberStack = new Stack<string>();
         GetSubcriptionList(subTarget, subscriptions, subscriberStack, lookupDictionary);
     }
     var executionOrder = lookupDictionary.GetExecutionOrder();
     Dictionary<string, bool> alreadyExecuted = new Dictionary<string, bool>();
     var result = executionOrder.
         SelectMany(exec =>
                        {
                            var subItems = exec.GetMySubscriptionsFromTargets();
                            subItems = subItems.Where(subItem =>
                                                          {
                                                              string keyValue =
                                                                  subItem.
                                                                      SubscriptionType !=
                                                                  SubscribeType_WebPageToSource
                                                                      ? subItem.ID
                                                                      : subItem.SubscriberRelativeLocation;
                                                              if (alreadyExecuted.ContainsKey(keyValue))
                                                                  return false;
                                                              alreadyExecuted.Add(
                                                                  keyValue, true);
                                                              return true;
                                                          }).ToArray();
                            return subItems;
                        }).ToArray();
     return result;
 }