public void Tick() { var old = _lastUpdated; _lastUpdated = DateTime.UtcNow; var difference = (int) (_lastUpdated - old).TotalMilliseconds; if (difference > 800) TimePeriodPassed(difference); }
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"); }