From 26f7b48631c63b718e3d47c8041345388de74e93 Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Mon, 27 May 2024 08:59:42 +0200 Subject: [PATCH] Make current download speed and ETA smoother --- src/KKManager.Updater/Windows/ModUpdateProgressDialog.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/KKManager.Updater/Windows/ModUpdateProgressDialog.cs b/src/KKManager.Updater/Windows/ModUpdateProgressDialog.cs index d4eee3e..0fadcb7 100644 --- a/src/KKManager.Updater/Windows/ModUpdateProgressDialog.cs +++ b/src/KKManager.Updater/Windows/ModUpdateProgressDialog.cs @@ -81,7 +81,8 @@ public static ModUpdateProgressDialog CreateUpdateDialog(UpdateSourceBase[] upda private async void ModUpdateProgress_Shown(object sender, EventArgs e) { - var averageDownloadSpeed = new MovingAverage(20); + var averageDownloadSpeed = new MovingAverage(25); + var averageDownloadSpeedFast = new MovingAverage(4); var downloadStartTime = DateTime.Now; UpdateDownloadCoordinator downloader = null; @@ -112,6 +113,7 @@ void DoStatusLabelUpdate(object o, EventArgs args) var downloadedSinceLast = FileSize.FromKilobytes((long)((_completedSize - lastCompletedSize).GetKbSize() / secondsPassed)); lastCompletedSize = _completedSize; averageDownloadSpeed.Sample(downloadedSinceLast.GetKbSize()); + averageDownloadSpeedFast.Sample(downloadedSinceLast.GetKbSize()); var etaSeconds = (_overallSize - _completedSize).GetKbSize() / (double)averageDownloadSpeed.GetAverage(); var eta = double.IsNaN(etaSeconds) || etaSeconds < 0 || etaSeconds > TimeSpan.MaxValue.TotalSeconds ? KKManager.Properties.Resources.Unknown @@ -122,7 +124,7 @@ void DoStatusLabelUpdate(object o, EventArgs args) var uploadSpeed = TorrentUpdater.GetCurrentUpload(); if (uploadSpeed.HasValue) text += $" | Seeding: {FileSize.FromBytes(uploadSpeed.Value)}/s"; - text += $"\r\nSpeed: {downloadedSinceLast}/s (ETA: {eta})"; + text += $"\r\nSpeed: {FileSize.FromKilobytes(averageDownloadSpeedFast.GetAverage())}/s (ETA: {eta})"; labelPercent.Text = text;