mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-03-02 11:57:05 +08:00
the speed progress bar shows test count
This commit is contained in:
@@ -50,7 +50,7 @@ func checkDownloadDefault() {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownloadSpeed(ipSet utils.PingDelaySet) (sppedSet utils.DownloadSpeedSet) {
|
||||
func TestDownloadSpeed(ipSet utils.PingDelaySet) (speedSet utils.DownloadSpeedSet) {
|
||||
checkDownloadDefault()
|
||||
if Disable {
|
||||
return utils.DownloadSpeedSet(ipSet)
|
||||
@@ -65,22 +65,25 @@ func TestDownloadSpeed(ipSet utils.PingDelaySet) (sppedSet utils.DownloadSpeedSe
|
||||
}
|
||||
|
||||
fmt.Printf("开始下载测速(下载速度下限:%.2f MB/s,下载测速数量:%d,下载测速队列:%d):\n", MinSpeed, TestCount, testNum)
|
||||
bar := utils.NewBar(testNum)
|
||||
bar := utils.NewBar(TestCount)
|
||||
for i := 0; i < testNum; i++ {
|
||||
speed := downloadHandler(ipSet[i].IP)
|
||||
ipSet[i].DownloadSpeed = speed
|
||||
bar.Grow(1)
|
||||
// 在每个 IP 下载测速后,以 [下载速度下限] 条件过滤结果
|
||||
if speed >= MinSpeed*1024*1024 {
|
||||
sppedSet = append(sppedSet, ipSet[i]) // 高于下载速度下限时,添加到新数组中
|
||||
if len(sppedSet) == TestCount { // 凑够满足条件的 IP 时(下载测速数量 -dn),就跳出循环
|
||||
bar.Grow(1)
|
||||
speedSet = append(speedSet, ipSet[i]) // 高于下载速度下限时,添加到新数组中
|
||||
if len(speedSet) == TestCount { // 凑够满足条件的 IP 时(下载测速数量 -dn),就跳出循环
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
bar.Done()
|
||||
if len(speedSet) == 0 { // 没有符合速度限制的数据,返回所有测试数据
|
||||
speedSet = utils.DownloadSpeedSet(ipSet)
|
||||
}
|
||||
// 按速度排序
|
||||
sort.Sort(sppedSet)
|
||||
sort.Sort(speedSet)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user