the speed progress bar shows test count
This commit is contained in:
parent
8eea8cdd0e
commit
2c46cfcd0f
6
main.go
6
main.go
|
@ -80,6 +80,9 @@ https://github.com/XIU2/CloudflareSpeedTest
|
|||
flag.Usage = func() { fmt.Print(help) }
|
||||
flag.Parse()
|
||||
|
||||
if task.MinSpeed > 0 && time.Duration(maxDelay)*time.Millisecond == utils.InputMaxDelay {
|
||||
fmt.Println("[警告] '-sl' 参数建议和 '-tl' 参数一起使用")
|
||||
}
|
||||
utils.InputMaxDelay = time.Duration(maxDelay) * time.Millisecond
|
||||
utils.InputMinDelay = time.Duration(minDelay) * time.Millisecond
|
||||
task.Timeout = time.Duration(downloadTime) * time.Second
|
||||
|
@ -112,7 +115,10 @@ func main() {
|
|||
if versionNew != "" {
|
||||
fmt.Printf("\n*** 发现新版本 [%s]!请前往 [https://github.com/XIU2/CloudflareSpeedTest] 更新! ***\n", versionNew)
|
||||
}
|
||||
endPrint()
|
||||
}
|
||||
|
||||
func endPrint() {
|
||||
if runtime.GOOS == "windows" { // 如果是 Windows 系统,则需要按下 回车键 或 Ctrl+C 退出(避免通过双击运行时,测速完毕后直接关闭)
|
||||
fmt.Println("\n按下 回车键 或 Ctrl+C 退出。")
|
||||
var pause int
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue