private static void AddMonitorOutputToStringBuilder(RateMonitor monitor5m, RateMonitor monitor1h, RateMonitor monitor24h, MonitorType monitorType, StringBuilder sb) { sb.Append($"{monitor5m.TotalEvents.ToString().PadLeft(7)} {monitor5m.AverageEventDuration:N4} {monitor5m.LongestEvent:N3} {monitor5m.LastEvent:N3} {((int)monitor5m.TotalSeconds).ToString().PadLeft(3)} - " + $"{monitor1h.TotalEvents.ToString().PadLeft(7)} {monitor1h.AverageEventDuration:N4} {monitor1h.LongestEvent:N3} {monitor1h.LastEvent:N3} {((int)monitor1h.TotalSeconds).ToString().PadLeft(4)} - " + $"{monitor24h.TotalEvents.ToString().PadLeft(7)} {monitor24h.AverageEventDuration:N4} {monitor24h.LongestEvent:N3} {monitor24h.LastEvent:N3} {((int)monitor24h.TotalSeconds).ToString().PadLeft(5)} - " + $"{monitorType}{'\n'}"); }
static ServerPerformanceMonitor() { for (int i = 0; i < monitors5m.Length; i++) { monitors5m[i] = new RateMonitor(); monitors1h[i] = new RateMonitor(); monitors24h[i] = new RateMonitor(); } }
private void MessageReceived(object sender, MessageEventArgs e) { if (e.User.Id == DiscordClient.CurrentUser.Id) { return; } Log.Logger.Verbose("{user}: {message}", e.Message.User.Name, e.Message.Text); RateMonitor.Analyze(e.Message); }
public ChunkDownloadManager(IMediaPlugin mediaPlugin, long maximumRequestRate = DefaultMaximumRequestRate) { MaximumRetryAttempts = DefaultMaximumRetryAttempts; MaximumConcurrentRequests = DefaultMaximumConcurrentRequests; Timeout = TimeSpan.FromMilliseconds(DefaultTimeoutMillis); _chunkDownloadStrategy = ChunkDownloadStrategy.AsNeeded; _mediaPlugin = mediaPlugin; _maximumRequestRate = maximumRequestRate; _requests = new DownloadRequestCollection(); _rateMonitor = new RateMonitor(); _refreshTimer = new DispatcherTimer(); _refreshTimer.Interval = TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis - DefaultTimeoutMillis); _refreshTimer.Tick += _refreshTimer_Tick; }
static ServerPerformanceMonitor() { for (int i = 0; i < monitors5m.Length; i++) { monitors5m[i] = new RateMonitor(); monitors1h[i] = new RateMonitor(); monitors24h[i] = new RateMonitor(); } for (int i = 0; i < cumulative5m.Length; i++) { cumulative5m[i] = new TimedEventHistory(); cumulative1h[i] = new TimedEventHistory(); cumulative24h[i] = new TimedEventHistory(); } }
public HistoryViewModel() { _rateMonitor = new RateMonitor(); _incomingQueue = new BlockingCollection <Transmission>(100); _conversation = new BatchObservableCollection <ConversationItemViewModel>(); _conversation.CollectionChanged += (sender, e) => ContentChanged?.Invoke(); _formatter = new PlainTextFormatter(); _updateTimer = new DispatcherTimer(); _updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 50); _updateTimer.Tick += (sender, arg) => OnUpdateUI(); PlainTextSelected = true; _rateMonitor.Start(); _updateTimer.Start(); Properties.Settings.Default.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(Properties.Settings.Default.HistoryEntries)) { // just switch out the queue, don't care about potentially lost items. _incomingQueue = new BlockingCollection <Transmission>(Properties.Settings.Default.HistoryEntries); } else if (e.PropertyName == nameof(Properties.Settings.Default.Encoding)) { ViewChanged(); } else if (e.PropertyName == nameof(Properties.Settings.Default.HistoryInfoTimestamp) || e.PropertyName == nameof(Properties.Settings.Default.HistoryInfoIpAdress)) { // force update. ViewChanged(); } }; }