Esempio n. 1
0
        /// <summary>
        /// Calculate system statistics
        /// </summary>
        private void CalculateStatistics()
        {
            CoefsOfChannelCapacity.Clear();
            BlockingProbability.Clear();
            AvgQueueLength.Clear();

            AbsoluteBandwidth       = Requests.Count(x => x.State == RequestState.Completed) / (double)Tact;
            RelativeBandwidth       = Requests.Count(x => x.State == RequestState.Completed) / (double)Requests.Count;
            DeclineProbability      = 1 - RelativeBandwidth;
            AvgTimeOfRequestInQueue = Requests.Sum(x => x.State == RequestState.Completed ? x.TimeInQueue : 0)
                                      / (double)Requests.Count(x => x.State == RequestState.Completed);
            AvgTimeOfRequestInSystem = Requests.Sum(x => x.State == RequestState.Completed ? x.ExistingTime : 0)
                                       / (double)Requests.Count(x => x.State == RequestState.Completed);
            AvgRequestsInSystem = _requestsInSystem / (double)Tact;

            foreach (IComponent component in Components)
            {
                if (component is Channel channel)
                {
                    CoefsOfChannelCapacity.Add(new KeyValuePair <string, double>(channel.ToString(),
                                                                                 channel.TactsChannelProcessed / (double)Tact));

                    if (component.GetType() == typeof(ChannelWithBlockingDiscipline))
                    {
                        ChannelWithBlockingDiscipline blockingChannel = component as ChannelWithBlockingDiscipline;
                        BlockingProbability.Add(new KeyValuePair <string, double>(blockingChannel.ToString(),
                                                                                  blockingChannel.TactsChannelBlocked / (double)Tact));
                    }
                }
                else if (component.GetType() == typeof(SourceWithBlockingDiscipline))
                {
                    SourceWithBlockingDiscipline source = component as SourceWithBlockingDiscipline;
                    BlockingProbability.Add(new KeyValuePair <string, double>(source.ToString(),
                                                                              source.TactsSourceBlocked / (double)Tact));
                }
                else if (component.GetType() == typeof(Queue))
                {
                    Queue queue = component as Queue;
                    AvgQueueLength.Add(new KeyValuePair <string, double>(queue.ToString(),
                                                                         queue.SumOfSizes / (double)Tact));
                }
            }
        }
Esempio n. 2
0
 public bool HasRequest(int userId) =>
 Requests.Count(requester => requester.PlayerData.Id == userId) > 0;
Esempio n. 3
0
 public int GetNumberOfRequests()
 {
     return(Requests.Count());
 }