Exemplo n.º 1
0
        public void ZeroAveragingPeriod()
        {
            var monitor = new SpeedMonitor (0);
            monitor.AddDelta (1000);
            monitor.Tick (1000);

            Assert.AreEqual (1000, monitor.Rate, "#1");
        }
Exemplo n.º 2
0
        public void Tick()
        {
            var monitor = new SpeedMonitor ();
            monitor.AddDelta (1000);
            monitor.Tick (1000);

            Assert.AreEqual (1000, monitor.Rate, "#1");
        }
Exemplo n.º 3
0
        public void TickTwice()
        {
            // Send 1000 bytes in 2000 milliseconds. Check
            // transfer rate is then 500bytes/second
            var monitor = new SpeedMonitor ();
            monitor.AddDelta (1000);
            monitor.Tick (1000);
            monitor.Tick (1000);

            Assert.AreEqual (500, monitor.Rate, "#1");
        }
Exemplo n.º 4
0
        public void TickFull()
        {
            // Averaging period is 3, tick 3 times.
            var monitor = new SpeedMonitor (3);
            monitor.AddDelta (1200);
            monitor.Tick (1000);
            monitor.Tick (1000);
            monitor.Tick (1000);

            Assert.AreEqual (400, monitor.Rate, "#1");
        }
Exemplo n.º 5
0
        public void Tick_AveragingTwo_TickThree()
        {
            // Send data only in the first tick. When we tick a third time
            // we should have a transfer rate of zero as the data should vanish.
            var monitor = new SpeedMonitor (2);
            monitor.AddDelta (1200);
            monitor.Tick (1000);
            monitor.Tick (1000);
            monitor.Tick (1000);

            Assert.AreEqual (0, monitor.Rate, "#1");
        }
Exemplo n.º 6
0
 public RequestMonitor()
 {
     announces = new SpeedMonitor();
     scrapes = new SpeedMonitor();
 }