示例#1
0
        /// <summary>
        ///     Initializes this latency monitor with the given interval and number of samples over which
        ///     the average latency is determined.
        /// </summary>
        /// <param name="latencyGrain"></param>
        /// <param name="interval"></param>
        /// <param name="numSamples"></param>
        /// <param name="performLatencyMeasurements"></param>
        /// <param name="endPointName"></param>
        public LatencyMonitor(
            ILatency latencyGrain,
            TimeSpan interval,
            int numSamples,
            bool performLatencyMeasurements,
            string endPointName = null
            )
        {
            if (latencyGrain == null)
            {
                throw new ArgumentNullException(nameof(latencyGrain));
            }
            if (interval < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(interval), "A positive interval must be given");
            }
            if (numSamples < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(numSamples), "1 or more samples must be specified");
            }

            _syncRoot = new object();
            _interval = interval;
            _performLatencyMeasurements = performLatencyMeasurements;
            _latencyGrain = latencyGrain;
            _measurements = new TimeSpanStatisticsContainer(numSamples);
            _endPointName = endPointName;
            _stopwatch    = new Stopwatch();
        }
示例#2
0
 /// <summary>
 ///     Initializes this latency monitor with the given interval and number of samples over which
 ///     the average latency is determined.
 /// </summary>
 /// <param name="latencyGrain"></param>
 /// <param name="settings"></param>
 /// <param name="endPointName"></param>
 public LatencyMonitor(ILatency latencyGrain,
                       LatencySettings settings,
                       string endPointName = null)
     : this(latencyGrain,
            settings.Interval,
            settings.NumSamples,
            settings.PerformLatencyMeasurements,
            endPointName)
 {
 }
示例#3
0
        public VirtualNetwork(ILatency latency, int delayPrecision, IPacketLossRate lossrate, int invokeThreads)
        {
            _latency = latency;
            _packetLossrate = lossrate;
            _delayPrec = delayPrecision;
            _dgramRingBuffer = new List<DatagramInfo> [(int)Math.Max (1, _latency.MaxLatency.TotalMilliseconds / delayPrecision)];
            for (int i = 0; i < _dgramRingBuffer.Length; i ++)
                _dgramRingBuffer[i] = new List<DatagramInfo> (1 << 14);

            _managementThread = ThreadTracer.CreateThread (ManagementThread, "VirtualNetwork.ManagementThread");
            _invokeThreads = new Thread[invokeThreads];
            _invokeStartHandles = new AutoResetEvent[_invokeThreads.Length];
            _invokeEndHandles = new AutoResetEvent[_invokeThreads.Length];
            for (int i = 0; i < _invokeThreads.Length; i ++) {
                _invokeThreads[i] = p2pncs.Threading.ThreadTracer.CreateThread (InvokeThread, "VirtualNetwork.InvokeThread" + i.ToString ());
                _invokeStartHandles[i] = new AutoResetEvent (false);
                _invokeEndHandles[i] = new AutoResetEvent (false);
            }
            _managementThread.Start ();
            for (int i = 0; i < _invokeThreads.Length; i ++)
                _invokeThreads[i].Start (i);
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ILatency AverageLatencyTotal = AverageLatency(false);
            ILatency AverageLatencyPM    = AverageLatency(true);
            ILatency TotalLatencyTotal   = TotalLatency(false);
            ILatency TotalLatencyPM      = TotalLatency(true);

            IRatings RatingsTotal = Ratings(false);
            IRatings RatingsPM    = Ratings(true);

            IUsers TotalUser = TotalUserCount();


            AverageLatencyCT.InnerHtml = AverageLatencyTotal.days + "d " + AverageLatencyTotal.hours + "h " + AverageLatencyTotal.minutes + "m ";
            AverageLatencyCP.InnerHtml = "<i class='green'>" + AverageLatencyPM.days + "d " + AverageLatencyPM.hours + "h " + AverageLatencyPM.minutes + "m  </i>From last month";

            TotalLatencyCT.InnerHtml = TotalLatencyTotal.days + "d " + TotalLatencyTotal.hours + "h " + TotalLatencyTotal.minutes + "m ";
            TotalLatencyCP.InnerHtml = "<i class='green'>" + TotalLatencyPM.days + "d " + TotalLatencyPM.hours + "h " + TotalLatencyPM.minutes + "m  </i>From last month";

            RatingsCT.InnerHtml = RatingsTotal.ratingCount.ToString();
            RatingsCP.InnerHtml = "<i class='green'>" + RatingsPM.ratingCount.ToString() + " </i>From last month";

            totalUsers.InnerHtml = TotalUser.userCount.ToString();
        }