private static void CountStats(object o) { if (DateTime.Now >= _timeLine) { _timeLine = _timeLine.AddSeconds(_config.CoreDelay / 5.0); var slot = _requestSlots[_currentSlotIndex]; if (_currentSlotIndex >= _requestSlots.Length - 1) { _currentSlotIndex = 0; } else { _currentSlotIndex++; } _currentSlot = _requestSlots[_currentSlotIndex]; slot.Reset(); var stats = new Dictionary <Guid, RawDomainStatistics>(); _requestSlots.Each(i => i.Gather(stats)); foreach (var statItem in stats.Values) { var selector = (IPageSelector)statItem; var statCount = statItem.Requests.ToList(); if (selector.SelectorType == (int)PageSelectorType.DomainPattern) { _statisticsModule.SetDomainRequests(new DomainSelector(DomainSelector.TotalDomain, selector.Id), statCount); } _statisticsModule.SetDomainRequests(selector, statCount); } } }
static RawGatheringRequestModule() { _config = ServiceLocator.Current.Resolve <IConfigurationModule>(); _statisticsModule = ServiceLocator.Current.Resolve <IDomainStatisticsModule>(); _handlers = Enumerable.Range(0, Environment.ProcessorCount * 2).Select(i => new GatheringRequestThread(i)).ToArray(); _requestSlots = Enumerable.Range(1, 5).Select(i => new GatheringRequestSlot(_handlers.Length)).ToArray(); _currentSlotIndex = 0; _currentSlot = _requestSlots[_currentSlotIndex]; _timeLine = DateTime.Now.AddSeconds(_config.CoreDelay / 5.0); _statsTimer = new Timer(CountStats, null, 0, 100); }