支持一下,不过有个建议:网速显示建议去掉b/s,最小单位为kb。不然显示感觉有点乱,而且低网速的时候,单位和字符长度一直跳来跳去
private string FormatSpeed(long bytesPerSec)
{
string[] units = { "KB/s", "MB/s", "GB/s" }; // 删除B/s,从KB开始
int unitIndex = 0;
double speed = bytesPerSec / 1024.0; // 直接转换为KB
while (speed >= 1024 && unitIndex < units.Length - 1)
{
speed /= 1024;
unitIndex++;
}
return $"{speed:F1} {units[unitIndex]}";
}